In this tutorial, we will discuss about Cucumber Testing Tool. However, before starting with Cucumber, we should know what Behavior Driven Development (BDD) is.
What is Behavioral Driven Development (BDD)?
BDD is a set of practices that helps to reduce the rework caused by misunderstanding or vague requirements, narrow the communication gaps between the development team, testing team, and customers and promote continuous communication among them. In BDD, tests are written in plain descriptive English (Gherkin) and they are more user-focused. As the tests are in plain English, so everyone like Business stakeholders, Business Analyst, QA Team, and Developers can contribute to testing. Cucumber is one such open-source tool, which supports Behavior Driven Development (BDD). In simple words, Cucumber can be defined as a testing framework, driven by plain English. It serves as documentation, automated tests, and development aid – all in one.
How Cucumber works?
- Cucumber reads the code written in plain English text (Language Gherkin) in the feature file.
- It finds the exact match of each step in the step definition.
- The piece of code to execute can be different software frameworks like Selenium, Ruby on Rails, etc.
- This has become the reason for Cucumber’s popularity over other frameworks, like JBehave, JDave, Easyb, etc.
Cucumber supports over a dozen different software platforms like −
- Ruby on Rails
- Spring Framework
Advantages of Cucumber Over other Tools
- Cucumber supports different languages like Java.net and Ruby.
- It acts as a bridge between the business and technical language. We can accomplish this by creating a test case in plain English text.
- It allows the test script to be written without knowledge of any code; it allows the involvement of non-programmers as well.
- It serves the purpose of an end-to-end test framework, unlike other tools.
- Due to simple test script architecture, Cucumber provides code re-usability.
Example of a Cucumber/BDD test:
Feature: Book flight ticket for one-way trip Scenario: Book flight ticket for one-way trip from Dublin to London Given I live in Dublin And I want to book one way flight ticket from Dublin to London for 23rd Oct 19 When I search Online Then TripAdvisor should provide me options of flight for 23rd Oct 19 And Cost of my flight should not be more than 50 Euro per person And Tickets should be refundable
Any Business User or Stakeholder can understand the above-mentioned test case. They can provide their feedback, on if this is expected from the functionality or not or do we need to add other steps too.