DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Running Selenium Cucumber Tests in Jenkins

Running Selenium Cucumber Tests in Jenkins

How to configure and run Selenium and Cucumber tests in Jenkins on a linux server.

Rajith Delantha user avatar by
Rajith Delantha
·
Oct. 08, 15 · Tutorial
Like (3)
Save
Tweet
Share
31.19K Views

Join the DZone community and get the full member experience.

Join For Free

This article shows how to configure and run Selenium (+ Cucumber) Tests in Jenkins. Before we dive into more details we have to have Jenkins installed in a server. Here is a quick way to setup Jenkins in a linux server.

OK all done, lets go though with the steps,

Step 1

First you need to install google chrome. This is called as chrome in headless mode. Because you really can't see the chrome window when you are running tests in Jenkins.

wget -qO - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -  
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'  
sudo apt-get update  
sudo apt-get install google-chrome-stable 

Step 2

Then install xvfb. OK what is this xvfb ?

Based on Wikipedia:

"Xvfb or X virtual framebuffer is a display server implementing the X11 display server protocol. In contrast to other display servers, Xvfb performs all graphical operations in memory without showing any screen output. From the point of view of the client, it acts exactly like any other X display server, serving requests and sending events and errors as appropriate. However, no output is shown. This virtual server does not require the computer it is running on to have a screen or any input device. Only a network layer is necessary."

sudo apt-get install xvfb  

Then start xvfb

 Xvfb :1 -screen 5 1024x768x8 &

Step 3

OK , server changes are done. Now its time to move into Jenkins configurations.

First install this plugin, (Jenkins -> Manage Jenkins --> Manage Plugins)

Why do you we need this ?

This plugin allows Jenkins to show Selenium + cucumber results as a graph with screenshots.

So in order to generate graphs this plugin need the report.json file that generated from Selenium + cucumber.

 @RunWith(Cucumber.class)  
 @Cucumber.Options(glue = {"classpath:com/rd/uat"}, strict = true, format = {  
     "pretty", "html:target/cukes", "json:target/cukes/report.json", "junit:target/cukes/junit.xml"})  
 public class RunCukes {  
 }  

Here is the plugin configuration in Jenkins.

Create Jenkins Job --> Then add this as "Post build Step"












Step 4

Add following environment variable to Jenkins. (Jenkins --> Manage Jenkins --> Configure System)

 DISPLAY=:1.5  

OK We just configure Jenkins to run selenium and Cucumber Tests.

Now run the Jenkins job and check the cucumber reports. :)

Here are some sample reports,







Jenkins (software) Cucumber (software) Testing

Published at DZone with permission of Rajith Delantha. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Last Chance To Take the DZone 2023 DevOps Survey and Win $250! [Closes on 1/25 at 8 AM]
  • The Role of Data Governance in Data Strategy: Part II
  • Exploring the Benefits of Cloud Computing: From IaaS, PaaS, SaaS to Google Cloud, AWS, and Microsoft
  • A Beginner's Guide to Back-End Development

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: