Photo by Shawn Lee on Unsplash

Test Automation 101: (6)Robot Framework and Jenkins Integration

*Please read the tutorial introduction, in case you haven’t yet. Here’s the link -> [LINK]

*Previous article in the tutorial series -> [LINK]

Our Robot Framework Project is almost complete. We have established a folder structure which already contains the required resources and test cases. We have the code-base stored in a remote repository.

Now, imagine that the number of test cases are growing. We have test suites that we need to run on a daily basis while for some, only during major patch releases. If we only use one machine to run all of our test cases, it would take forever to complete. We need to be able to run test cases in parallel. For daily executions, we need a tool to where we can put the scheduled runs.

This is where Jenkins come in handy. It allows you to setup VMs where the test execution can be done so that your test cases can run in parallel. You can also schedule test suites to run on a daily basis, weekly, or whatever frequency you desire. There are a lot of other features in Jenkins, look it up if you want to know more. What I want to share here is how we can use Jenkins in the context of Test Automation.

Before we start, what we will be doing here is to setup Jenkins in our local machine, trigger our test cases from Jenkins and view the results there.

Let’s get to it!

  1. Download Jenkins (link) The version used here is 2.204.1.
  2. Launch the installer and proceed with the installation.
  3. Post-installation, follow the instructions here -> https://jenkins.io/doc/book/installing/#windows
  4. If you were able to follow the instructions, you should arrive here:

5. Go to Manage Jenkins -> Manage Plugins ->Available Tab. Type “Robot Framework” in the filter textbox near the upper-right corner of the window.

6. Tick the checkbox for Robot Framework plugin and click “Install without restart.”

7. Once installation is complete, go back to the Jenkins homepage -> New Item. Enter an item name then click OK.

  • Note: You will be directed to the configuration page. There are a lot of features that you can utilize, for now our goal is to simply be able to trigger our existing test suite using Jenkins.

8. Add a build step ->Execute Windows batch command.

This is the command that I used. If you installed python in a different location, please make the adjustments accordingly. For the --suite argument, it is just the folder structure going down until the name of the robot file.

"C:\Program Files\Python37\python.exe" -m robot.run --pythonpath C:\ProgramFiles\Python37\Lib\site-packages --suite TestAutomationPractice.Testcases.SmokeTest.LoginPage C:\TestAutomation\TestAutomationPractice

For a more detailed reference about the arguments when running via command line, you may refer to this -> https://robot-framework.readthedocs.io/en/v3.0.4/_modules/robot/run.html

9. Add a post-build action -> Publish Robot Framework test results. Keep the default values.

10. Click Apply then Save.

11. Click Build Now.

There will be an entry in the build history sub-window to indicate that the Jenkins job is running.

Once done, it should look like this.

It will show a report of the total # of tests, fail and pass count, and % of passed test cases. You can also drill down to the report and log files for investigation purposes, in cases there are any errors.

Jenkins use cases:

  1. Daily run of tests — you can configure the Jenkins job to run automatically on a daily basis and send a report directly to your email.
  2. Parallel execution — you can setup Jenkins in a server machine, have several slave machines where the actual execution will occur. Once that it setup, you may be able to run several Jenkins jobs in parallel.
  3. Test Suites dependency — if you have test suites that have dependency, for example, Test Suite A needs to be executed first before Test Suite B, that is possible to be configured in Jenkins.
  4. Automatic checkout from repository — say you have a repository for your project, for example Github, you can configure the job to automatically checkout the latest version of the project before executing the test suite.

There are many other reasons why using Jenkins in testing is useful, the examples above are some of the simplest ones.

Hooray! This is the last part of the series Test Automation 101. Congratulations for completing the tutorial series. I really hope it helped you get started in Test Automation.

Any comments or suggestions will be greatly appreciated. Thank you!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store