jenkins run test code example
Example 1: what test you have on jenkins
I personally set up 2-3 jobs for automated tests
One for smoke - > Smoke is running daily 2,3 times a day , making sure
that all environments are up and running
- Full regression (80% automation 20% manual)?
* Before each production release(after 3 sprints)
* Only very stable test cases are stored in full regression
* Updating functionality
- Minor regression
* Runs at the end of sprint
* Tests that are related to certain modules and functionalities
* I use tags to specify which module to run
Example 2: 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.