Definition
Plain language
A line in a test that says "this should equal that," and fails the test if it doesn't.
As stated in the literature
A check inside a test that compares actual program behavior against an expected value; assertion failures dominate the false rejections produced by model-authored test suites.
Also called: assertions, assertion failure, assertion failures
Why it matters: Assertions are where a wrong expected value does its damage: if the expected number is off, a perfectly good program gets marked as broken.
For example, a test for a function that adds numbers might contain the line "check that add(2, 3) equals 5," and the test fails the moment the function returns anything else.
Heard on the show
“Because a suite is a list of assertions: for this input, the output should be that.”Episode 233 — Why a Model Can Grade an Answer But Not Write the Answer Key