Loading

Cucumber


In the field of software engineering, Behaviour Driven Development(BDD) is the one of the emerging development approach, based on the passing of the acceptance testing criteria, for each feature or functionality, to be development.

In Behaviour Driven Development, firstly, test scripts are created for each of the functionality or requirements, in the consultation with the developers/programmers and the users/client/stakeholder and thereafter, developed code is made to pass through these test cases. If the code fails, it is refactored/corrected accordingly, to pass these test cases.

cucumber

It is one of the unique methodology, where test scripts are made first, and accordingly codes are developed to pass these tests, so as to ensure that all the codes, being developed are meeting the specified requirements and specifications.

To Support the development process, using BDD approach, there are numerous tools and frameworks, are readily available in the market. Cucumber is one of the widely known and used tool/framework, used for the purpose of supporting the behaviour driven development. So, let's have an overview of the cucumber, so as to understand, its advantage and preference over other tools/frameworks.

Cucumber

Cucumber is an open source tool/framework, built for the purpose of supporting behaviour driven development methodology. This tool is used in developing the acceptance test scripts for the purpose of automation, especially for the web applications, by implementing business rules and requirements, along with the possible test scenarios.

It is written in the ruby programming language. However, it is a cross platform tool and may be used for other projects also, involving programming languages, other than the ruby.

This tool makes use of the Gherkin parser, a plain English text, used for the purpose of defining and creating the test cases. This plain English text, helps in defining and outlining the user stories, business requirements, test scenarios, etc. in a non-technical and a simple readable & understandable format, so as to provide easiness to the developers, testers, along with the non-technical users, such as business analyst, users, etc., to have clear understanding of the product and prevents the consideration of unambiguous requirements.

Basic Characteristics

The Cucumber software tool usually comprises of feature file, which may be further divided into following components:

Features: It may be seen as a use case, which is used to represent a specific or a particular functionality that needs to be tested. Each feature is a combination of several scenarios.
Scenario: A scenario is used to define and describe a particular functionality, under the test. It is mainly used to visualize and interpret the various possible work-flow, associated with that particular functionality. Each scenario speaks about the test, to be performed, in a very simple and easily understandable language, i.e. in gherkin. Further, it states the steps and possible outcomes for a test case.
Given: It represents the current state of a feature, under the test. It states the pre-specified condition.
When: It reflects the certain task or operation, to be executed under the test.
Then: It defines the possible and expected outcomes, after the execution of the test.
And: Used to connect two statements, stating two different tasks or actions, to be performed.
Step Definition: It makes use of the 'Given', 'When' and 'Then', to map the test cases, specified in the feature file, to the functionality that needs to be tested.

Key-Points

  • An Open Source tool, for supporting the behaviour driven development.
  • Originally written in Ruby, but may be used for other platforms also, with the help of gherkin parser.
  • It supports web environment only.
  • It supports multiple languages apart from the ruby, such as Java, Scala, etc.
  • It may be run either by the JUnit Runner or by the TestNG.