Friday, April 24, 2015

What is Cucumber?

Technorati Tags: ,,
Cucumber – a Behavior Driven Development (BDD) framework which is used with Selenium / Capybara for performing acceptance testing.

Cucumber is a tool based on Behavior Driven Development (BDD) framework which is used to write acceptance tests for web application. It allows automation of functional validation in easily readable and understandable format (like plain English) to Business Analysts, Developers, Testers, etc.

Feature files are essential part of cucumber which is used to write test automation steps or acceptance tests. All the feature files ends with .feature extension.
Sample feature file:

Feature: Math operations

I want to run the Math operations and check the functionality

Scenario: Addition operation

Given user provide two numbers a & b
When user choose Add operation
Then the result of a+b should be displayed



Feature, Scenario, Given, When and Then are the keywords, rest all is a plane English.

Feature:
It describes a breif details about the functionality that the Feature file tests

Scenario:
Scenario represents a particular functionality which is under test. It gives the information about the test is all about. Each scenario should follow given, when and then format. This language is called as “gherkin”.

  • Given: specifies the pre-conditions. It is basically a known state.
  • When: This is used when some action is to be performed. In our above example, user choose add operation
  • Then: The expected outcome or result should be placed here. In the above example, result of a+b is the expected result.
  • Background: Whenever any step is required to perform in each scenario then those steps needs to be placed in Background. Typically we use Background when the feature files contains multiple scenarios and when there are some common steps to be executed before running each of the scenario. Consider a web application, which requires user login for each and every scenario. Then we will place user login step in the Background
  • And: And is used to combine two or more same type of action.
    more info

  • No comments:

    Post a Comment