Integrating Selenium Java Cucumber Tests with Jenkins

In the world of test automation, combining Selenium, Cucumber, and Jenkins creates a powerful CI/CD testing pipeline. Selenium handles browser automation, Cucumber enables behavior-driven development (BDD), and Jenkins provides continuous integration. Together, they ensure your web applications are tested automatically with every code update. This blog will walk you through the process of integrating Selenium Java Cucumber tests with Jenkins for a fully automated testing workflow.


Why Integrate Selenium and Cucumber with Jenkins?

Continuous Testing: Automatically run tests every time code is pushed to a repository.

Early Bug Detection: Catch issues before they reach production.

Test Reporting: Get real-time feedback and detailed reports via Jenkins dashboards.

Team Collaboration: QA, developers, and business stakeholders can work together using human-readable test scenarios in Cucumber.

Prerequisites

To follow along, you should have:

A Java project with Selenium WebDriver and Cucumber set up (Maven or Gradle based).

Jenkins installed (locally or on a server).

Git repository (e.g., GitHub, GitLab, Bitbucket).

Basic knowledge of Gherkin and Cucumber structure.


Project Structure

Your Maven project should be structured like this:


bash


src

 └── test

     └── java

         └── stepDefinitions

         └── runners

         └── pageObjects

     └── resources

         └── features

pom.xml

Make sure your pom.xml includes dependencies for Selenium, Cucumber, JUnit/TestNG, and Maven plugins.


Step 1: Create Jenkins Job

Open Jenkins and click on "New Item".

Enter a job name and select "Freestyle project".

Click OK to configure the job.


Step 2: Connect Git Repository

In the project configuration:

Scroll to Source Code Management.

Select Git and enter your repository URL.

Add credentials if needed.


Step 3: Configure Build Triggers

Set up Jenkins to trigger builds automatically:

Enable "Poll SCM" if you want Jenkins to check for changes periodically.

Use a cron-like syntax (H/5 * * * *) to poll every 5 minutes.

Alternatively, configure a webhook from your Git repo for push-based builds.


Step 4: Define Build Steps

Under Build, choose "Invoke top-level Maven targets" and enter:


bash


clean test

This runs your Selenium-Cucumber tests via Maven. Ensure the maven-surefire-plugin or maven-failsafe-plugin is correctly configured in your pom.xml.


Step 5: Generate Test Reports

Add plugins for test reporting:

Install Cucumber Reports Plugin in Jenkins.

In Post-build Actions, select "Publish Cucumber reports".

Set the report path (e.g., target/cucumber-reports/Cucumber.json).

This will show beautiful test result dashboards directly in Jenkins.


Optional: Add Email Notifications

Configure Jenkins to send test result summaries to your QA or Dev teams:

Use the Email Extension Plugin.

Define triggers like “Unstable” or “Failed” builds to notify the team.


Conclusion

Integrating Selenium Java and Cucumber tests with Jenkins automates the entire testing lifecycle—from code check-in to test execution and reporting. This integration ensures that your application is continuously tested, quality is maintained, and bugs are caught early. It also brings developers and QA engineers closer through a shared understanding of test scenarios, making your CI/CD pipeline more collaborative and efficient.


With this setup in place, your team is well-equipped to ship faster, safer, and smarter.

Learn Selenium with Java  Course  in Hyderabad

Read More: Automating AJAX Calls in Selenium Java

Read More: Automating Double Click and Right Click Events in Selenium Java
Read More: Automating Web Tables in Selenium WebDriver Java

Visit Quality Thought Training Institute Hyderabad
Get Direction

Comments

Popular posts from this blog

Tosca vs Selenium: Which One to Choose?

Flask API Optimization: Using Content Delivery Networks (CDNs)

Using ID and Name Locators in Selenium Python