Cucumber testing framework that supports Behavior Driven Development (BDD). It is used to develop tests for testing the behavior of software functionality. It is mainly used to write acceptance tests for web applications as per the behavior of their functionalities.
In the BDD process, the scenarios or acceptance tests are written first by the business analyst that describes the behavior of the system from the user perspective. The acceptance tests are further verified and signed off from the product owner before starting with the development process.
The language that Cucumber understands is called Gherkin. Gherkin is a domain-specific language for the behavior-driven framework (BDD). Gherkin is business readable. It follows the ‘Given-When-Then’ statements for writing test cases
Language Supported by Cucumber
Features include in Cucumber Testing:
- Integration with all the most popular testing libraries;
- Specifying the behavior looking at the system from the outside;
- Defining executable specifications in different ways like lists, prose, and tabular data;
- The plain text files can be stored in any version control system;
- Collaboration and coming up with a good and clear set of Acceptance Criteria.
Basic Terms in Cucumber
- Feature file – Contains tests written in Gherkin (plain English text)
- Feature – Contains information about the feature to be a test
- Step definition file – Contains the actual code written by the developer
- Given-When-Then – GWT statements
- Tags – Label attached to the tests
- Scenario – Contains the scenario details which is supposed to be tested
Cucumber Testing Example
The main objective of Cucumber is to write Acceptance tests. The tests are written in simple texts which makes it easy for anyone in the team to understand the feature.
Scenario: Successful Login
Welcome message on successful login
Given the user is on the login page
When user entered correct username and password
Then the user should be successfully navigated to home page
And should see a personalized greeting message
Advantages of Cucumber
The test scripts are written in very simple language thus having in-depth knowledge of programming is not required.
The setup steps are very simple and easy
It provides an end-to-end testing framework
It works as a bridge between the business and technical teams, and this bridge is sustainable because of test cases written in plain English text.
It is a well efficient tool for testing.
Difference between Cucumber vs Selenium
|Cucumber is a Behavior Driven Development tool||Selenium is an automation framework|
|Cucumber is a free or open-source BDD tool||Selenium is also a free or open-source testing tool.|
|Cucumber is written in Ruby programming language||Selenium is mainly written in Java|
|The plugin in cucumber works faster.||Plugins are slower than a cucumber.|
|Test scripts are written based on GWT scenarios||Test scripts are written based on test cases and requirements|
|Cucumber scripts can be easily readable||Selenium scripts are difficult to read by a non-programmer|
|It is easy to write, develop, and execute scripts.||Selenium scripts are more complicated to develop and execute|
|Cucumber has a quick setup and installation.||Selenium installation is difficult comparatively|
|Cucumber makes the execution of scripts a little slower.||Selenium has quite good performance in executing test scripts.|
|Cucumber framework supports multiple languages like Java, Scala, Groovy, etc. beyond Ruby.||Selenium also supports multiple languages, such as Java, .Net, etc.|