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
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
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.
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.
Setup a build trigger that suits your workflow. You can also set the job up to run on demand.
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
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.