BDD derives from TDD
Behavior-driven Development (Behavior-driven development, referred to as BDD) is a software development approach based on test-driven development (Test-driven DEVELOPMENT,TDD). The biggest drawback of TDD is that it often feels impossible to face a lot of functional requirements and use cases. On the other hand, since TDD is more focused on testing itself, it is easy to ignore the expression of business needs and eventually indulge in trivial details.
BDD avoids loss of information
Compared with the traditional method of software development, the essence of BDD is to avoid the loss of information that occurs during the translation process, such as requirement description, use case writing, code implementation, testing, etc. To this end, BDD takes use cases and example example as the core, and uses some unique concepts such as Gherkin and a series of BDD-specific tools to achieve a complete realization of the software requirements in a way that is closer to the business scenario. The comparison between the two is as shown.
Traditional software development process
BDD development process BDD process
Each iteration of BDD can be expressed as:
- Plan the entire system and get abstract business objectives Goal
- Refine your business objectives into a number of specific functional requirements feature
- Take Given-when-then three-segment, describe and demonstrate specific features with specific scenario examples example
- Convert example to executable specification
- The specification is disassembled into a lower-level, approximation code-implemented low-level specification and testing test
- Get the code implementation from low-level specification and extract the active document living documentation
Gherkin
Gherkin, which is the text used in BDD to describe a specific business scenario example example, takes a specific format. It is more specific than the requirements specification specification, somewhat similar to the use case, but more concrete and vivid. It can be used as a test script and as an archived content.
Feature: Transferring money between accounts
on order to Manage my money more efficiently
as a bank client
I want to transfer funds between my accounts whenever I need to
Scenario: transferring money-a savings account
Given my Current account has a balance of 1000.00
and my Savings Account have a balance of 2000.00
when I transfer 500.00 From my current account to my Savings account
then I Should has 500.00 in my current account
and I should Has 2500.00 in my Savings account
Behavior-Driven Development BDD essence