The Given-When-Then formula is a template intended to guide the writing of acceptance tests for a User Story:
- (Given) some context
- (When) some action is carried out
- (Then) a particular set of observable consequences should obtain
An example:
- Given my bank account is in credit, and I made no withdrawals recently,
- When I attempt to withdraw an amount less than my card’s limit,
- Then the withdrawal should be complete without errors or warnings
Tools such as JBehave, RSpec, or Cucumber encourage the use of this template, though it can also be used purely as a heuristic irrespective of any tool.