Join us
How to configure Jenkins to run RobotFramework test cases
❓The problem
I wanted to demonstrate that implementing an automation testing and continuous integration system might not be so difficult after all, and the benefits will be worth the cost.
💡The Solution
I need a simple short and fast example of how to integrate the existing framework with a tool that allows running the test base in triggers
🔧The Implementation
Use Jenkins to automate the test case execution and create a simple and fast example of how it is set up.
Initial setup
Download Jenkins
Jenkins can be downloaded on:
Jenkins is available for different OS, such as Windows, Mac, and Linux.
There are some hardware pre-requisites:
Install Jenkins
On windows, a .msi
file will be downloaded which can facilitate the installation.
I can run the wizard to install it.
I need to select the logon type (in my case, the option Run service as LocalSystem
is enough, but in a production environment might be better be safe and select the next option)
The last step is to set the port where I will run Jenkins, by default will be 8080
⚠️ Troubleshooting: Make sure Java is already installed in the system
If everything is correct, I should be able to use the browser to navigate to the localhost with the port selected, for example http://127.0.0.1:8080
and we will find the Jerking welcome page.
If this is the first time using this instance of Jenkins, it will ask for a password stored in a specific location.
Customize Jenkins
Jenkins will provide a shortcut to get the plugin if this is the first time I am using this instance
For now, I will choose to Install suggested plugins
Creating the administrator user
If this is the first time using the instance Jenkins will ask for the creation of an administrator account.
After creating the user, Jenkins will ask couple more questions for the setup and then it is done.
Installation with .war
file
If instead of downloading the installer, I decided to download the .war
file I need to follow:
.war
filejava -jar jenkins.war
☝🏾 It is easier if I navigate to the location of the file using windows explorer, once in the file location, on the top bar I use cmd+enter and
this will open cmd
in that location (check the gif bellow).
This will open Jenkins in the default port 8080
however, if I want to open it in a different location I can use
Adding the Robot Framework plugin
Jenkins allows adding a plugin that helps with the automation, in this case, I want to use Jenkins to run the Robot framework test, so I need to install the robot framework plugin
2. Locate manage plugins
3. Switch to the Available tab and search for robot framework
4. Check the box and later install without restart.
How to Create a job in Jenkins
To create a job I can start by:
2. Select the Freestyle project
3. Once on the configuration page, I need to tell Jenkins to execute the test case, I can do that using the built section and selecting Executing Windows batch command
if I am running Jenkins in windows and Execute Shell
if I am in Linux or MAC.
4. In this space, I need to navigate to the folder where the .robot
files representing the test case are and run the robot command
5. I need to tell Jenkins where to publish the Framework test results, for that I need to configure the Post-build Actions.
6.In the section post-built Actions, select Publish Robot Framework test results
I can either provide the full path to the directory of Robot Output
or I can define a custom workspace and shorten the path.
Run the Robot Framework Job
Once the job is created and everything is configured I can run the job by clicking on build now
Before continue
Troubleshooting
The Builds are shown as failed
but if I inspect the result they say the test passed,
This is because I made a mistake during the configuration, I have the following
Step 4 is the build
but robot -d Result VideoSearch_Android.robot
is not a valid command, and I can prove this by checking the test console output
Here I can see what the console printed
So the test is passing, but due to my mistake of adding a not recognized internal command, Jenkins reported it as failed.
The solution
Remove the command robot -d Result VideoSearch_Android.robot
from step 4.
Show HTML reports on Jenkins
Robot Framework will generate some reports but if I try to see it on Jenkins I will get some errors like this :
So I need to make some small changes
The problem
There is some issue with the Content Security Policy and by default Jenkins will block the HTML results generated by the Robot framework
The solution
Unset the header, for this, I can use the command
I need to go to the correct place to paste this command
4. Paste the command here
☝🏾 You will need to run the test again.
🤖Robot Results
Now to see the general result and some useful graphics I can go to robot results
Final Thoughts
Join other developers and claim your FAUN account now!
Influence
Total Hits
Posts
Only registered users can post comments. Please, login or signup.