2.7. Something Different

  • What if we could do something different?

  • Specify & write tests – But not tightly coupled with the APIs.

  • Specify what you want to happen, not how. You may ask what is the difference between What and How?

    What:

    Maps to specification

    How:

    Maps to implementation

  • Whatever tests we specify now, should be executable.

  • So Test Specification is more or less equal to Test Implementation.

  • So avoid Test Implementation stage after the review of Test Specifications.

2.8. Given, When, Then

Generally speaking, almost all our tests can be specified under these three keywords:

GivenWhenThen

../../_images/given-when-then.jpeg
Given:

Some existing pre-condition.

When:

Some action happens.

Then:

Then there is a re-action / effect.

And, that’s the key to BDD.

All tests in BDD are defined using these keywords. These are called scenarios in BDD.