Assertion
The statement in a test that must hold, and the only part that can actually fail.
An assertion is the check inside a test that decides pass or fail. Everything else in a test is setup; the assertion is the specification.
Several properties separate a useful assertion from a decorative one.
It must be reachable. An assertion after a step that can throw never runs on a broken path. An assertion placed outside the claim it supports cannot fail inside that claim — a structural trap in any system where claims are recorded per assertion.
It must be able to fail. See Falsifiability and Vacuous Truth. Checking that a class is present when the question is whether the class resolves to anything is the commonest form of a passing assertion that proves nothing.
It should assert the invariant, not the incidental. An assertion pinned to a value that legitimately varies — a token count, an exact sentence, a generated identifier — will break on every unrelated regeneration and be read as a failure.
Its failure message should identify the problem. A message naming the expected condition saves more time than any amount of test structure.
A related discipline: when a test is written after a fix, revert the fix and watch the assertion go red before trusting it. The counts confirm it — a suite going from two failing to zero is evidence; a suite that was already green is not.
See also6
Falsifiability
A claim is only worth something if you know what observation would refute it.
Method46 connections
Vacuous Truth
A statement that holds only because its subject set is empty — a green result that measured nothing.
Method26 connections
Test-Driven Development
Writing a failing test first, making it pass, then improving the code with the test as a net.
Testing & Verification10 connections
LLM-as-Judge
Using a language model to score another model's output against a rubric.
Agents & Language Models10 connections
Fail Fast
Crash at the point of misconfiguration rather than degrading quietly into a wrong state.
Method18 connections
Nondeterminism
The property that identical inputs may produce different outputs, and what it costs to test around.
Agents & Language Models23 connections
Related3
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from11
- Binary SearchComputation & Algorithms
Finding a value in a sorted range by repeatedly discarding half of it.
- Fail FastMethod
Crash at the point of misconfiguration rather than degrading quietly into a wrong state.
- FalsifiabilityMethod
A claim is only worth something if you know what observation would refute it.
- Golden File TestingTesting & Verification
Comparing an output against a checked-in reference file the whole team agreed was correct, rather than an inline assertion.
- LLM-as-JudgeAgents & Language Models
Using a language model to score another model's output against a rubric.
- Mutation TestingTesting & Verification
A test-of-tests that injects small bugs into code and checks whether the existing suite catches them, exposing tests that assert nothing.
- NondeterminismAgents & Language Models
The property that identical inputs may produce different outputs, and what it costs to test around.
- Property-Based TestingTesting & Verification
Asserting a general property that should hold for all inputs, then letting the framework generate many random inputs to try to break it.
- Snapshot TestingTesting & Verification
Comparing a component or output's current rendering against a saved baseline, flagging any difference for a human to accept or reject.
- Test-Driven DevelopmentTesting & Verification
Writing a failing test first, making it pass, then improving the code with the test as a net.
- Vacuous TruthMethod
A statement that holds only because its subject set is empty — a green result that measured nothing.