code under test
The particular function, class or module a test is exercising and making claims about.
In more detail
Everything else in a test exists to set up, call or observe this one piece of code. Keeping it clearly identified is what makes a test readable. Never replace part of the code under test with a test double, or the test ends up checking its own assumptions instead of your code.
Related terms
- automated test — A small program that runs part of your code and checks that it did what you claimed it would.
- test double — Any object that replaces a real dependency in a test: a stub returns canned data, a fake is a small working implementation, and a mock checks interactions.
- 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.
Taught in
- The Cost And Value Of A Test — Automated Testing, TDD & Quality Engineering
- Arrange, Act, Assert — Automated Testing, TDD & Quality Engineering
- Introducing pytest — Automated Testing, TDD & Quality Engineering
- What Test Doubles Are For — Automated Testing, TDD & Quality Engineering