Introduction to Cucumber
More than a testing tool, Cucumber is a collaboration tool.
It is designed to accommodate both the technical(developers, automation testers) and non-technical(stakeholders, product owners) members of the software development team.
Cucumber supports behavior-driven development(BDD). In BDD, users(business analysts, product owners) first write scenarios or acceptance tests that describes the behavior of the system from the customer’s perspective, for review and sign-off by the product owners before developers write their codes.
When you run your test, Cucumber reads through user-readable files called features, parse it to scenarios which contains set of steps that are then matched to a step definitions of Ruby code using a regular expression.
Feature files could be deceiving. It may look simple and plain in the outside. But complex in the inside, within step definition or the ruby files which controls the flow of actions and where all the magic happens.
In order for Cucumber to understand the feature files, it uses a basic syntax called Gherkin. Gherkin makes use of the following keywords for documentation and readability — Feature, Background, Scenario, Given, When, Then, And, But, *, Scenario Outline and Examples.
In preparation to your Cucumber testing experience, will be needing to setup the following in your local machine.
1. Java installation – JRE will do, mine is Java(TM) SE Runtime Environment 1.6
2. Ruby installation – visit their Downloads page. I have Jruby 188.8.131.52 installed in my box.
Don’t forget to define Java and Ruby Path in your system’s environment variables as well.
3. RubyGems installation – use “gem install <name of gem>” command. Here are some of the basic, helpful gems:
If you’re all setup, feel free to jump to the next post – Automated Testing with Cucumber + Capybara
Reference: The Cucumber Book by Matt Wynne and Aslak Hellesoy