Kelly Mears

Assertion

The statement in a test that must hold, and the only part that can actually fail.

Testing & Verification2 min read225 words12 out · 16 in
also calledAssertions

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 also10

Test-Driven Development

Writing a failing test first, making it pass, then improving the code with the test as a net.

Testing & Verification12 connections

LLM-as-Judge

Using a language model to score another model's output against a rubric.

Agents & Language Models12 connections

Regression

A previously working behavior that a change has broken.

Method23 connections

Fail Fast

Crash at the point of misconfiguration rather than degrading quietly into a wrong state.

Method27 connections

Nondeterminism

The property that identical inputs may produce different outputs, and what it costs to test around.

Agents & Language Models24 connections

Silent Failure

A failure that produces no signal, so the absence of an error reads as success.

Method73 connections

Hallucination

Fluent, confident output that is not grounded in anything real.

Agents & Language Models21 connections

Defensive Programming

Writing code that anticipates misuse and bad input, checking assumptions and handling the unexpected rather than trusting callers, along with the debate over when defense should give way to failing loudly.

Testing & Verification11 connections

Design by Contract

Specifying what each function requires and guarantees, as checkable preconditions, postconditions, and invariants, so a violation says exactly whose bug it is.

Testing & Verification12 connections

Core Dump

A snapshot of a crashed program's memory saved for later inspection, how to get one, how to read one, and why it can leak secrets.

Systems & Tooling11 connections

Linked from16