How does Specification-Driven Development work?

BDD Jul 04, 2021

Specification-Driven Development (BDD 2.0) works in the following way:

  1. 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.
  2. Execution of the specification must fail first, to prove it will catch situations where the feature doesn't work.
  3. Engineers write code to create the feature and deliver it.
  4. 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:

  1. 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.
  2. 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.
  3. 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 "myUniqueEmail@testrigor-mail.com" into "Email"
enter "4111111111111111" into "Card"
click "Place order"
validate if page contains "order placed successfully"
check that email to "myproductcompanyuniqueemail@tesrigor-mail.com" 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 "myUniqueEmail@testrigor-mail.com" was delivered

where the reusable business rule purchase Product is defined as:

click "Cherry Blossom Popup Bouquet"
click "Add to cart"
click "Cart"
enter "myUniqueEmail@testrigor-mail.com" into "Email"
enter "4111111111111111" into "Card"
click "Place order"
Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.