I want to deploy a proxy and then post-deployment I want to run test cases in POSTMAN only. Is there a way that it can be run in one command. I don't want to use Junit or SOAP UI or any other tool for testing
Solved! Go to Solution.
You should be using Newman which is what Postman uses behind the scenes to execute the test cases in your postman collection. For more info, check this link.
To execute this using the Maven pom, you first need to make sure the machine executing the pom has NodeJS installed as newman used in my code is using newman npm
Include a package.json file in your proxy project, the file should include
{ "name": "some-proxy", "version": "1.0.0", "dependencies": { "newman": "^4.3.0", "prettyjson": ">=1.1.3", "jsonfile": ">=2.3.1", "lodash": ">=4.15.0", "bluebird": "^3.3.5" } }
Note: I have included many other npm dependencies which you might not need
In your pom.xml, include these lines of code. The first execution contains the installation of node modules from the package.json and then running the newman module by passing the path of the postman collection and environment json.
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3.2</version> <executions> <!-- npm install --> <execution> <id>npm-install</id> <phase>test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>npm</executable> <commandlineArgs> install </commandlineArgs> </configuration> </execution> <!-- Integration Testing--> <execution> <id>integration-tests</id> <phase>install</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>node_modules/newman/bin/newman.js</executable> <commandlineArgs> run target/test/integration/oauth.postman_collection.json -e target/test/integration/oauth.postman_environment.json </commandlineArgs> </configuration> </execution> </executions> </plugin>
Try this out and see if it works