Reputation: 2566
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.
Upvotes: 5
Views: 8155
Reputation: 51
Additionally you can integrate newman available into Maven docker image and run as pipeline.
spec:
containers:
- image: "miksonx/node-newman-maven"
imagePullPolicy: "Always"
name: "maven"
tty: true
"""
...
stages {
stage('Unit Test') {
agent{
kubernetes {
yaml NodeNewmanMaven
}
}
steps {
container(MVN_AGENT) {
sh 'mvn clean integration-test'
}
}
}
https://miksonx.wordpress.com/2021/04/19/postman-newman-using-maven-under-jenkins-kuberenets/
Upvotes: 0
Reputation: 3306
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>
Upvotes: 5