- Cucumber Tutorial
- Cucumber - Home
- Cucumber - Overview
- Cucumber - Environment
- Cucumber - Gherkins
- Cucumber - Features
- Cucumber - Scenarios
- Cucumber - Annotations
- Cucumber - Scenario Outline
- Cucumber - Tags
- Cucumber - Data Tables
- Cucumber - Comments
- Cucumber - Hooks
- Cucumber - Command Line Options
- Cucumber - JUnit Runner
- Cucumber - Reports
- Cucumber - Debugging
- Cucumber - Java Testing
- Cucumber - Ruby Testing
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Cucumber - Overview
In order to get better advantage of the software testing, organizations are nowadays taking a step forward. They implement important acceptance test scenarios while development is in-progress. This approach is commonly known as Behavior Driven Development (BDD).
Behavior Driven Development gives us an opportunity to create test scripts from both the developer’s and the customer’s perspective as well. So in the beginning, developers, project managers, QAs, user acceptance testers and the product owner (stockholder), all get together and brainstorm about which test scenarios should be passed in order to call this software/application successful. This way they come up with a set of test scenarios. All these test scripts are in simple English language, so it serves the purpose of documentation also.
If we are developing a user authentication feature, then the following can be few key test scenarios, which needs to get passed in order to call it a success.
The user should be able to login with correct username and correct password.
The user should not be able to login with incorrect username and correct password.
The user should not be able to login with correct username and incorrect password.
How it Works
By the time the code is ready, test scripts are ready too. The code has to pass the test scripts defined in BDD. If it does not happen, code refactoring will be needed. Code gets freezed only after successful execution of defined test scripts.
It is a very simple notion, but what we need in order to get this concept implemented. The answer is, Behavior Driven Development (BDD) Framework. Cucumber is one such open source tool, which supports behavior driven development. To be more precise, Cucumber can be defined as a testing framework, driven by plain English text. It serves as documentation, automated tests, and a development aid – all in one.
So what does Cucumber do? It can be described in the following steps −
Cucumber reads the code written in plain English text (Language Gherkin – to be introduced later in this tutorial) in the feature file (to be introduced later).
It finds the exact match of each step in the step definition (a code file - details provided later in the tutorial).
The piece of code to be executed can be different software frameworks like Selenium, Ruby on Rails, etc. Not every BDD framework tool supports every tool.
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 end-to-end test framework unlike other tools.
Due to simple test script architecture, Cucumber provides code reusability.