BDD Living Documentation using Yard-Cucumber

BDD Framework like Cucumber aims to bridge gap between business and technology. In BDD we describe behavior of software as plain text in .feature file. Cucumber helps us wrap business language around test code so that there is better visibility and tests are not lost in code. Sharing documentation within and across teams is an important aspect and there are currently different solutions available to host and share .feature files. I have used Relish in the past for hosting feature files online. Cucumber.pro also looks promising for collaboration. I came across a post from Shashikant here about living documentation using Yard-Cucumber and wanted explore more.  Yard-Cucumber is  a free tool which can be used to generate documentation interface to view features, tags etc. It generates HTML files and is a nice interface to search/view features and tags. In his blog post Shashikant shows how to use Yard-Cucumber for a ruby cucumber project. I attempted to use Yard-Cucumber for a cucumber-jvm project and share my experience in this blog post. Here are the steps,

Make sure you have ruby 2.0.0 installed

Go to your project and install bundle if its not installed already.

gem install bundle
bundle init

This will create a Gemfile in your project. Add gems below,
gem "yard-cucumber"
gem "redcarpet"
gem "rake"

Then execute,
bundle install

Now lets create Rakefile and add contents below,

require 'yard'
YARD::Rake::YardocTask.new(:yard) do |t|
t.files = ['src/test/resources/features/**/*.feature', 'src/test/java/**/*.java']
end

Now Yard-Cucumber is configured successfully and now you should be able to run the tool to generate reports,
bundle exec rake yard

Now you should see doc folder under your project. index.html should be the launching pad. My sample project is hosted on github here and you can take a look at my docs over here (give it a few seconds to load).

Some images from my project are like,

featuressearch

Advertisements

4 thoughts on “BDD Living Documentation using Yard-Cucumber

  1. It didn’t work Nilesh. My feature file looks like this.
    @addition
    Feature:Addition
    #In order to do addition of two numbers
    #As a an accountant
    #I want a feature two add two numbers in calculator

    Scenario Outline:Addition_of_numbers
    Given I enter “”,””
    When I add them together
    Then the result is “”

    @int_add
    Scenarios:As_integers
    | num1 | num2 | result |
    | 10 | 20 | 30 |
    | 3 | 34 | 37 |

    @float_add
    Scenarios:As_float
    | num1 | num2 | sum |
    | 20.0 | 10.0 | 30.0 |
    | 30 | 15.0 | 45.0 |
    @negative_add
    Scenarios:negative_numbers
    | num1 | num2 | sum |
    | -10 | 20 | 10 |
    | 20 | -30 | -10 |
    | -20 | -30 | -50 |
    Exception:
    [warn]: Syntax error in `src/test/resources/com/epsilon/agility/automation/dines
    h/add.feature`:(14,7): syntax error, unexpected ‘|’, expecting end-of-input
    [warn]: ParserSyntaxError: syntax error in `src/test/resources/com/epsilon/agili
    ty/automation/dinesh/add.feature`:(14,7): syntax error, unexpected ‘|’, expectin
    g end-of-input
    [warn]: Stack trace:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s