Acceptance tests: from a vague criterion to examples

level 1 · 20 min · acceptance test-driven development (ATDD)

In ATDD, acceptance tests are born before the code, in a conversation between whoever knows the business, whoever develops and whoever tests. The guiding question is: how will we know this story is done? The answer becomes acceptance criteria, and each criterion becomes one or more tests.

A criterion is only useful with concrete examples. “The coupon gives a discount” accepts any discount. “A $50.00 cart with the coupon BEM10 ends at $45.00” accepts only one. Writing in the given, when, then format helps separate the situation, the action and the result.

Rule of thumb. For each criterion, write a case with exact values and a result you can check, preferably at the limit of the rule. If the test passes with the wrong rule, it still lacks detail.

Read the story and the criterion

This story arrived for refinement. Before any code, try to find out what an acceptance test would need to check.

As a customer, I want to apply a 10% coupon to my cart so I pay less.

Acceptance criterion: the coupon gives a discount on the order.

Questions to ask in the conversation

  • A discount of how much, and on what: items, shipping or both?
  • Is there a minimum order value? Does the discount apply at the exact value?
  • What happens with a coupon already used, expired or mistyped?
  • From this text alone, can anyone say when the feature is done?

Exercise: choose the acceptance cases

After the conversation, the team settled the rules: the coupon BEM10 gives 10% on the items, on orders of $50.00 or more, and each customer uses it only once. For each criterion, choose the test case that proves it.

Discount at the minimum valueCriterion: a $50.00 order with the coupon BEM10 gets a 10% discount.
Order below the minimumCriterion: an order below $50.00 does not accept the coupon.
Coupon already usedCriterion: each customer uses the coupon BEM10 only once.
Expired couponCriterion: an expired coupon is refused.
Code that does not existCriterion: a code that does not exist is refused without losing the cart.

Choose a test case for each criterion.

References

  • ISTQB® Certified Tester Foundation Level v4.0, section 4.5, Collaboration-based Test Approaches. © ISTQB®.