Integrating BDD Cucumber Test Suites in Jenkins in 3 Steps

   DevOps and Tools
Integrating BDD Cucumber Test Suites in Jenkins in 3 Steps

cucumber-161610_1280

Behaviour Driven Development improves communication between Developers, Testers and the product owners and over a period of time we end up having a large suite of tests that need to be run very often. To have tests running regularly, it is key that we integrate test suite execution with our CI tool chain. Constantly challenging test suites is an important part of our job here at Modus Create; our current favorite CI tools include Jenkins, Bamboo, and CircleCI.

In my previous blog post Using Cucumber to write BDD tests for an Extjs 5 App I wrote about how we could use Cucumber and Watir-webdriver to test Ext JS 5 applications. In this post I will walk you through Jenkins integration in 3 easy steps.

Step 1: Install Dependencies

Install these there plugins that are required to build a bare minimum test suite

Rake plugin – A make-like build utility for Ruby

Rvm – Helps you manage multiple versions of Ruby

Xvfb Plugin (for headless linux OS) (Optional) if you want to run tests on a headless linux machine.

Step 2: Create a new freestyle project and configure the Job

Navigate to the configuration page and setup the project to checkout a copy of the source code. If you are setting this up on a Linux/Mac machine use RVM. image002

Begin by making sure you have installed the required version of ruby and set it up on the configurations page as below. Make sure you have installed the bundler gem by running

> gem install bundler

image003

If you are using a linux headless machine you might want to select the Start Xvfb checkbox. Xvfb is not required on a Windows or Mac machine.

Setup subversion or git to checkout code. We will be using https://github.com/bkone/cukeit in this post.

Step 3: Add a build step to install your dependencies:

Depending on your operating system select the appropriate task to execute shell or execute windows batch and enter the following command. That will install all the required dependencies.

> bundle install

Now set up the rake task that you would want to run. In our case it would be “rake regression” which will run all the scenarios tagged @regression in the feature file. See the Rakefile for all the available rake tasks.

image004

Setup a build trigger that suits your workflow. You can also set the job up to run on demand.

Test Reports

The built-in reporting feature in cucumber is great, there are also some useful plugins which can enhance cucumber reports. Some of the plugins you can try are

Cucumber Reports Plugin

Cucumber Test Result Plugin

Conclusion

This setup should get you going but real success depends on analyzing test results after every run. After result analysis take the necessary action to resolve any failures. If you are using a similar Ruby/cucumber setup please give this a try and share your results in the comments below.


Like What You See?

Got any questions?