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 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.

$ gem install bddfire 1 $ gem install bddfire

Or include BDDfire in the Gemfile

gem 'bddfire' 1 gem 'bddfire'

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

$ bddfire Commands: bddfire fire_cucumber bddfire fire_rspec bddfire generate_yard bddfire help [COMMAND] bddfire version 1 2 3 4 5 6 7 $ bddfire Commands : bddfire fire_cucumber bddfire fire_rspec bddfire generate_yard bddfire help [ COMMAND ] bddfire version

The commands will look like this in the terminal.

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

$ bddfire fire_cucumber 1 $ bddfire fire_cucumber

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 :

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

$ bundle install 1 $ bundle install

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

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

$ bundle exec cucumber 1 $ bundle exec cucumber

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

$ bundle exec cucumber -p poltergeist 1 $ bundle exec cucumber - p poltergeist

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 :

$ bundle exec relish push {Publisher}/{project} 1 $ bundle exec relish push { Publisher } / { project }

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.

$ bundle exec cuke_sniffer 1 $ bundle exec cuke_sniffer

Using Rubocop

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

$ bundle exec rubocop 1 $ bundle exec rubocop

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.

$ bundle exec cucumber -p browserstack 1 $ bundle exec cucumber - p browserstack

Testingbot

$ bundle exec cucumber -p testingbot 1 $ bundle exec cucumber - p testingbot

Saucelabs

$ bundle exec cucumber -p sauce 1 $ bundle exec cucumber - p sauce

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

$ npm install 1 $ npm install

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

$ ./node_modules/.bin/appium 1 $ . / node_modules / .bin / appium

Now that we can run cucumber cucumber

$ bundle exec cucumber -p appium 1 $ bundle exec cucumber - p appium

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.

$ bundle exec rake features $ bundle exec rake cuke_sniffer $ bundle exec rubocop 1 2 3 $ bundle exec rake features $ bundle exec rake cuke _ sniffer $ bundle exec rubocop

CI Integration

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

$ ./ci_script features 1 $ . / ci_script features

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 :

@home_page = HomePage.new(Capybara.current_session) @home_page.visit_home_page 1 2 @ home_page = HomePage .new ( Capybara .current_session ) @ home_page .visit_home_page

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

https://github.com/Shashikant86/bddfire/

Video Demo