automated test
A small program that runs part of your code and checks that it did what you claimed it would.
In more detail
A test is a claim about behaviour written as code, so a machine can check it again on every change without getting tired. It buys you permission to change code safely. It also costs something: it is code that has to be read, kept passing and updated when the behaviour changes on purpose.
Example
def test_two_lines_add_up():
assert total([(250, 2), (125, 4)]) == 1000Related terms
- assertion — A check that a condition is true, which stops a test or program with a failure if it is false.
- test suite — A collection of tests run together to check a piece of software.
- code under test — The particular function, class or module a test is exercising and making claims about.
- regression — A bug where something that used to work stops working, or works worse, after a change.
Taught in
- The Cost And Value Of A Test — Automated Testing, TDD & Quality Engineering
- Arrange, Act, Assert — Automated Testing, TDD & Quality Engineering
- One Assertion Per Reason — Automated Testing, TDD & Quality Engineering