Cucumber is a software testing tool and nowadays it is famous in the market because it is based on BDD (Behavior Driven Development). Cucumber testing software runs automated acceptance tests written in a behavior-driven development (BDD) style.
It has a stable release on 13 July 2018.
It is basically written in Ruby programming language. Cucumber uses Gherkin language to define the test cases. It is used for cross platform and you can use this tool in many programming languages like Java, .Net, Nodejs, PHP, etc.
What is Behavior Driven Development?
It encourages collaboration between everyone involved in developing software like developers, testers, and business representatives such as product owners or business analysts.
What is the goal of BDD?
the main goal of BDD is to improve the collaboration between all stakeholders involved in developing software like developers, testers, and business representatives such as product owners or business analysts and form a shared understanding among them.
Cucumber has two basic components known as features and scenarios.
What are features?
Features are a file with a .feature extension that has multiple scenarios.
What are Scenarios?
Scenarios are plain English statements that completely state what the feature is and what it is supposed to perform. They are actions taken by the user and the outcome of these actions in the form of a response from the website.
Features file has 3 sections.
Given – These steps are used to set up the initial state before you do your test.
When – These steps are the actual test that is to be executed.
Then – These steps are used to assert the outcome of the test.
Example:- to create the file name simple_calculation.feature extension and write the below code in this
# features/simple_calculation.feature Feature: Simple math calculation I want to check the increment variable result Scenario: easy math calculations Given a variable set to 4 When I increment the variable by 5 Then the variable should contain 9