Behavior-Driven Development (BDD)
Behavior-Driven Development (BDD) is one of the process related to software development that emerged from TDD (Test-driven Development). Behavior-Driven Development combines the general principles and techniques of test-driven development with ideas from objected oriented analysis and design and domain-driven design to provide software development and with shared process and shared tools of management teams to collaborate on software development.
The practice of BDD includes the use of software tools that are specialized to support the development process.
Automation Testing Using Cucumber Tools and Selenium
- Based on the Behavior Driving Development (BDD) framework Cucumber is a tool that is used to write acceptance tests for web applications. It allows automation of functional validation in understandable and readable format to Developers, Testers, Analysts Etc.
- Feature Files related to Cucumber serve as a good document for all. Cucumber, initially was implemented in Ruby and extended to framework related to Java. Cucumber can well be used along with Watir, Selenium and Capybara etc.
Lets understand what is Cucumber?
Cucumber is one of the testing framework that helps to bridge the gap between business managers and software developers. Based on the Behavior-Driven Development (BDD) style, tests are written in plain language that helps a layperson to understand. Cucumber allows software development teams to describe how software should behave in a plain text. The text is written in a domain-specific business-readable specific languages and serve as development-aid, automated tests and as documentation into one format.
Why to use Cucumber?
Cucumber allows to write documentation related to feature in Plain Text. It means you could sit with your Business Analyst or Client to write down the related features to be built on your application. To bridge the gap between development team and business people this framework has a great potential.
- Feature: A feature would describe the current test script which has to be executed.
- Scenario: For a particular test case, scenario would describe the expected outcome and steps
- Background: Before each scenario, background describes the steps that would be executed.
- Scenario Outline: We can execute the same scenarios for multiple sets of data, using scenario outline. The data is provided in a tabular structure(separated by | |). By providing the column header in angular brackets(< >) the step definitions can be parameterized. For each parameter, double quotes needs to be put in the table and not in the step definition.
- Given: ‘Given’ specifies the context of the text to be executed. Given step can also be parameterized using data tables.
- When: ‘When’ specifies the test action to be performed.
- Then: ‘Then’ specifies the expected outcome of the test.
- In each step definition within double quotes(“”), parameters can be passed. It will read as Regex format. Tags can be provided for different features, backgrounds or scenarios. In determining the specific scripts that would be executed, the tags would help.
How cucumber helps in Test Automation
When we mention the scenarios in feature files and run it in IDE (eclipse) it will design the test cases for you. All you need to do is writing a suitable logic for that particular test case. When the requirements get changed, we need to write the new scenarios in the feature file and apply the suitable logic.