So If you have set up your API Automation project with the Karate framework, and now you are planning to run your automated test cases with the help of Jenkin, you can do it by creating jobs in your Jenkin.
You can create a Jenkin job as a freestyle project or you can create with the help of a pipeline.
Here in this article, we will try to create a freestyle job in Jenkin for API Automated test cases. We can follow below steps:
Steps 1: Click on New Item, give a name for your API Automation
Step 2: Select Maven project
Step 3: Click on Ok. It will load the configuration page. Select or make sure JDK is selected.
Step 4: Now select the source code management. in this case, git. Copy the git URL for your project.
Step 5: Enter the git repo URL along with branch detail.
Step 6: Now in the pre-build step, enter the shell (Linux or mac) or batch command (windows)
mvn clean test -DargLine='-Dkarate.env=e2e' -Dkarate.options="--tags @Smoke" -Dtest=CucumberReport -DfailIfNoTests=false
There are 3 parts to this command:
mvn clean test: It will search the test class.
Dkarate.env: It will set up the environment, in this case e2e
Dkarate. options tag: It will set up the tags.
Step 8; Make sure in the build section, pom is coming.
Step 7: In post-build action, use cucumber report. (Cucumber report plugin need to be added in Jenkin).
If it is added, it will come in the option.
Step 8: Click on advanced
Step 9: Enter the report path. (This path is for karate 1.0.1)
Step 10. Click on Save.
Step 11: Click on Build Now.
Step 12: After the build is successful, You will see the cucumber report.
No comments:
Post a Comment