BDD (behavior-driven development) - is a set of software engineering practices designed to help teams build and deliver more valuable, higher quality software faster . It draws on Agile and lean practices including, in particular, Test-Driven Development (TDD) and Domain-Driven Design (DDD). BDD is not software development methodology in its own right. It’s not a replacement for Scrum, XP, Kanban, RUP, or whatever methodology you’re currently using.
BDD Process
-
The business owner and the business analyst have a conversation about what the business needs
-
The business analyst, the developer, and the tester elaborate the requirements together. They define requirements as structured, English-language format "scenarios"
-
The scenarios guide the developer and act as automated tests
-
The tester uses these scenarios as the basis for the tests
-
The automated tests provide feedback on progress and help document the application
-
Given describes the preconditions for the scenario and prepares the test environment
-
When describes the action under test
-
Then describes the expected outcomes
-
The And and But keywords can be used to join several Given, When, or Then steps together in a more readable way
The main feature of all BDD frameworks is mapping text steps into method of program language by using regular expressions.
Example of GUI Scenario
Scenario: Running a Full Text Quick Search.
Given I perform Quick Search by "IPhone 4S"
When I click on link 'Search History' on panel 'Quick Search'
Then the term query "IPhone 4S" should be the first in the Search History grid
Note: Text description of scenarios uses Gherkin language
Pros
-
The acceptance criteria are nice thought
-
Test logic is in total independent layer of implementation
-
We get executable specification
-
All test cases and automated tests are up to date
-
Application development time reduced
-
Manual qa engineer can use automated test scenarios for manual testing
-
BA could accept user-story base on test execution report
-
Manual or Junior qa automation engineers help qa team develop automated tests
Cons
-
It is not possible to do testing in the middle of the test. Checks are made only in the THEN section
-
It's hard to maintain reusable steps in the scenarios. Very often it leads to duplication of code in the test system
-
It is difficult to refactor tests
-
It is necessary to create and maintain the Domain Dictionary for writing tests
-
The complexity of writing test scenarios without Helper-s ( typos, say the phrase can be different )
Define workflow of scenarios creation with team.
-
BA writes draft of scenarios or requirements in classical style and puts them into Jira story
-
QA reviews scenarios, rewrites them, asks BA additional questions and puts final version of scenarios into Jira story
-
BA approves the final version of scenarios and put comment about it
-
User story is ready for development
Create the initial version of the Domain vocabulary/Templates of BDD steps.
The most important step of BDD tests creation is to define abstract layer (strong technical or non-technical) of BDD steps. It should be understandable for Business (PO, DM, BA and etc.) and for technical engineers (developers, QA engineers, DevOps and etc.).
Limitations
-
Most difficult things in BDD are create good test system architecture and define «Rules of the game»
-
BDD is a very good approach. But this is not a silver bullet
-
To use or not to use BDD depends on situation and project
-
Tests Stability and BDD usability depends on you