given, when, then
A way of describing a test or requirement as a starting situation, an event, and the expected outcome.
In more detail
It is the same idea as arrange, act, assert, phrased in words a non-programmer can follow. It comes from behaviour-driven development, where scenarios are written in this form before the code. It is also a useful shape for test names: the subject, the behaviour and the condition.
Related terms
- arrange, act, assert — A three-step shape for a test: set up the starting state, perform the one behaviour under test, then check the observable result.
- test naming — Choosing test function names that state the behaviour and the condition, so a failure summary reads as a sentence.
Taught in
- Arrange, Act, Assert — Automated Testing, TDD & Quality Engineering
- Naming Tests For Readability — Automated Testing, TDD & Quality Engineering