jenkins regression testing code example
Example 1: what is the command for regression test in jenkins
For Cucumber Framework:
verify -Dcucumber.options="--tags @regression" or
verify -Dfile = "RegressionRunner.java" ==>
If you have a seperate RegressionRunner class in your framework
For TestNG Framework:
test -Drunner=regression_runner.xml
test -Drunner=smoke_runner.xml
Example 2: regression testing command jenkins
For Cucumber Framework:
verify -Dcucumber.options="--tags @regression" or
verify -Dfile = "RegressionRunner.java" ==>
If you have a seperate RegressionRunner class in your framework
For TestNG Framework:
test -Drunner=regression_runner.xml
test -Drunner=smoke_runner.xml
Example 3: how to connect test to jenkins
enter into search box ip:8081 or ip:8080 to hit Jenkins.
default port for Jenkins is 8080. In our case, it was switched to 8081.
web application - any application used over the browser.
Steps to create a smoke test job:
I write the name of the test, such as smoke-test.
1. Source Code Management Section
here we specify where to get the code from. we put the link to our
GitHub repo and also enter the credentials
2. Build Triggers
I specify how often I run those tests. I choose Build periodically
because I want to run in certain schedule. In my project, I run smoke
tests every morning at 6 am. So in the build trigger I entered daily option:
H 6 * * * --> every day 6 in the morning
3. Build Section
I enter the details of the actual run. Since my project is based
on maven, I choose option: invoke top-level maven targets then I choose
which maven to run from the version dropdown. In the next field, I enter
the maven goal: test. In this field we do not need to enter the word mvn.
I also mention here which tag I want to run. So the command will be:
test -Dcucumber.options="--tags @smoke"
4. Add Post-build Actions
In the post build actions, I configure what I want to to after the ends.
After each test I generate report and email to my team members.
For Report, I select cucumber reports plugin from the post-build actions to
generate reports.
For email, I select Editable Email Notification option from the Post-build
Actions to send emails to my team.