BDD (Behavior Driven Development)
A more recent approach is BDD (Behaviour Driven Development), which emerged from TDD (Test Driven Development). Behavior-driven development combines the general techniques and principles of TDD with ideas from Domain driven design and Object oriented analysis & design to provide software development and management teams with shared tools and a shared process to collaborate on software development.
Although BDD is principally an idea about how software development should be managed by both business and technical teams, the practice of BDD does assume the use of specialized software tools to support the development process. Although these tools are often developed specifically for use in BDD projects, they can be seen as specialized forms of the tooling that supports test driven development.
BDD is largely facilitated through the use of a simple domain-specific language (DSL) using natural language constructs (e.g., English-like sentences) that can express the behavior and the expected outcomes. Test scripts have long been a popular application of DSLs with varying degrees of sophistication. BDD is considered an effective technical practice especially when the business problem to solve is complex.
Gherkin is one of these DSLs and follows the structure:-
- Given, When, Then, And, But (Steps)
- Scenario Outline
The DSL is useful in describing the function to both developers and testers.
Cucumber is often used in association with Selenium using an IDE such as Eclipse or IntelliJ (both open source). The tests are enhanced using TestNG and they can be run from a Maven command line and create rich reports.