BDD

BDDfire : An Instant Ruby-Cucumber BDD Framework

BDDfire

I am glad to announce ‘BDDfire‘ : An instant Ruby-Cucumber BDD framework which supports various popular open-source libraries like Capybara, Selenium-WebDriver, Poltergeist, Relish, Cuke_sniffer, Rubocop, Appium, Saucelabs, Browserstack etc etc.BDDfire will create all the directories and required files to support the latest open-source libraries in the Ruby-Cucumber framework.

BDDfire is a rubygems and we can install and use it in any brand new Cucumber project or existing Cucumber framework.

BDDfire source code is available on the Github. In this post, we will explore BDDfire in the detail.

bddfire_rubygems

BDDfire Features

Cucumber is a very popular BDD framework. Cucumber become more effective when it’s plugged with other open -source libraries. Sometime we miss most of the useful libraries to be used with Ruby-Cucumber. BDDfire supports lots of modern open-source libraries  so that we won’t miss new trends in the world of Ruby-Cucumber.

BDDfire has following features:

  • BDDfire will create template directories and files for the Cucumber project.
  • Capybara and WebDriver Integration for executing acceptance scenarios in the real browsers
  • Capybara and Poltergeist integration to execute scenarios in the headless browsers.
  • Generate template directories to support RSpec
  • BDDfire supports cuke_sniffer and Rubocop libraries which detect smell in the Ruby-Cucumber framework.
  • BDDfire supports Relish for the living documentation.
  • Rakefile has been automatically created as a part of BDDfire
  • BDDfire  supports YARD documentation of the cucumber project.
  • BDDfire allow you write steps using Page Object Pattern 

 

BDDfire Installation

With BDDfire, you can install Ruby-Cucumber BDD framework with all those libraries in a single command.

Or  include BDDfire in the Gemfile

Once installed we can make use of the BDDfire in our existing project. BDDfire commands will be listed when you run ‘bddfire’

The commands will look like this in the terminal.

bddfire_install

 

BDDfire Usage

Now that, we have installed BDDfire. We need to create Ruby-Cucumber framework and make use of it.

Generate & Install Ruby-Cucumber Framework

BDDfire will install entire Ruby-Cucumber BDD framework in a single command

This will create all the directories and the files with required code in it. This will create Gemfile and Rakefile if they are not already in the project. Th typical output will look like this :

fire_cucumber

Now that we have got new Gemfile. We need to install bundle to get the dependencies installed on our project.

This will create a ‘Gemfile.lock’ file. Now our Ruby-Cucumber Framwork looks like this

bddfire_framework

Using Selenium-WebDriver

Now we have installed ‘Selenium-Webdriver‘ and in the cucumber.yml file, we have selenium as a ‘default’ profile. We can execute our scenarios using

Using Headless Poltergeist

Poltergeist is the headless driver for the Capybara. We have created a profile for the Poltergeist in the cucumber.yml. Poltergeist execute scenarios in the headless browser based on PhantomJS

Using Relish

Relish allows us to push feature file online as a living documentation. We have already got ‘.relish’ file in out BDDfire framework. We need to get relish api token. You need to have relish account and project created in the relish. Please use my previous blog to setup Relish.

Now you can push all the features to relish :

Using Cuke_Sniffer

Cuke_Sniffer is a library which detects smell in the cucumber project. You can refer previous blog about cuke_sniffer to get detailed installation and usage.

Using Rubocop

Rubocop is the library to detect smell in the Ruby code. We have installed rubocop can be executed like this :

Using Cloud Testing Frameworks

Saucelabs, Testingbot and Browserstack are the cloud testing framework. You need to have Saucelabs/Testingbot/Browserstack account and API key to use it. We have Capybara driver register ‘features/support/env.rb’. We need to add Saucelabs/Testingbot/Browserstack related details.

Testingbot

Saucelabs

Using Appium

Appium is a very popular mobile test automation framework. You can refer my previous post to more about Cucumber-Appium setup. Make sure you have required setup before using Appium. Here we have ‘package.json’ file. You need have NodeJS installed so that we can install Appium

This will install Appium in the ‘node_modules’ directory. We can then start Appium Server.

Now that we can run cucumber cucumber

Using Rake Tasks

BDDfire creates some rake tasks by default. We have a Rakefile which has three tasks. Rake task ‘features’ will execute all the features with selenium deiver. Rake task ‘ cuke_sniffer’ and ‘rubocop’ execute bundles for relevant libraries.

CI Integration

Currently, you can use the script ‘ci_script’ on Jenkins or Hudson. You need pass rake rask to the script

Page Object Pattern

BDDfire allows us to write steps using  Page Object Pattern. Page object pattern is great way to maintain the automation framework by abstracting locators and common methods to the Page classes. BDDfire has created directory called “features/pages” which has ‘Abstract.rb‘ and ‘HomePage.rb” files. We can create instance of these classes at any point in the steps_definitions like this :

This makes our step_definitions more stable. We need to change page classes if something changed and step_definitions remains unchanged.

Contributing to BDDfire

I bet, you have better ideas to contribute to BDDfire. You can fork the repo on the github. Things to do are

  • Adding pre-defined steps for the Poltergeist and Selenium Driver. User will utilise step_definitions from BDDfire.
  • Adding steps for Appium
  • And many many things

Video Demo