How does Specification-Driven Development work?
Specification-Driven Development (BDD 2.0) works in the following way:
- Product Owner creates a specification in plain English that describes how the new feature needs to function. This specification is executable on its own with no coding required.
- Execution of the specification must fail first, to prove it will catch situations where the feature doesn’t work.
- Engineers write code to create the feature and deliver it.
- Executable specification must run successfully to allow the feature to be promoted to production. If the run is not successful, then the feature is assigned to fixed or the specification is reviewed for correctness.
Differences with the BDD 1.0 specification are as follows:
- In SDD specification is executable. No need to create any test code. In BDD, it is a two-step process: first the specification is created, then test code is written to implement the specification after the feature is written.
- The SDD specification must be able to run and fail before the feature is delivered as in TDD-style. The is an advantage over the BDD where specifications are not executable and, therefore, it can be unclear if the feature has been implemented correctly. More over, SDD demands that the executable specification (all test code) is done before coding of the feature had started.
- However with SDD there is no chance of discrepancies between the specification and the test code, since the specification is executable on its own.
Example of SDD with testRigor based on the plain English support:
click "Cherry Blossom Popup Bouquet"
click "Add to cart"
click "Cart"
enter "[email protected]" into "Email"
enter "4111111111111111" into "Card"
click "Place order"
validate if page contains "order placed successfully"
check that email to "[email protected]" was delivered
Alternatively, the SDD specification can be organized in a way to leverage reusable business rules. This is similar to the way modular coded functions are reused:
purchase Product
validate if page contains "order placed successfully"
check that email to "[email protected]" was delivered
where the reusable business rule purchase Product
is defined as:
click "Cherry Blossom Popup Bouquet"
click "Add to cart"
click "Cart"
enter "[email protected]" into "Email"
enter "4111111111111111" into "Card"
click "Place order"