Issue
I have postman.collection.json files and I am able to run those collections files through newman and using the below command.
newman run test.postman.collection.json -e environment.collection.json -d test.csv
It ran successfully and is giving a response back.
I just want to get the same behavior by using the maven system. I need to integrate it with pom.xml, so that file will run the above collection.
Is this possible? If it's possible to run like this, then please share a sample to show how.
Solution
There are some unofficial postman runners for Maven, like this or this. I've never tried those, so I couldn't recommend either of them.
I prefer to use the maven-exec-plugin
to run postman / newman collection during the integration-test
or verify
lifecycle phases.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>
<!-- PATH_TO_NEWMAN_EXECUTABLE-->
</executable>
<commandlineArgs>
run <!--PATH_TO_COLLECTION_JSON--> -e <!--PATH_TO_ENVIRONMENT_JSON-->
</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
Answered By - zforgo
Answer Checked By - Marilyn (JavaFixing Volunteer)