LLearnCode
Academy/production/Verification

intermediate · 24 minute study

Choose the test that can actually prove the claim

One green test is not evidence for every layer of a feature. The right test reaches the boundary where the claimed behavior is enforced.

Loading progressEvidence grows with practice
Useful preparation · 1 prerequisite

Use this as a map, not a lock. If these ideas are familiar, continue.

First, build a mental model

A test surrounds a contract with controlled inputs and observable outputs. Its authority ends at the boundaries it replaces with mocks.

  1. Unit tests isolate small logic contracts. Integration tests exercise cooperating components such as a data adapter and database. E2E tests follow user-visible flows through the deployed-style application.
  2. A mock is a controlled substitute, not evidence that the substituted system behaves as imagined. Use it to isolate a question and document the boundary it removes.
  3. Fixtures should be small, named and isolated. Include missing, malformed, boundary and unauthorized cases that could falsify the claim.
  4. Coverage reports tell you which code ran, not whether assertions detected wrong behavior. A test pyramid is a cost/feedback guide, not a quota to satisfy blindly.
Read the codejavascript · educational example
import test from 'node:test';
import assert from 'node:assert/strict';

test('one toy order line totals integer cents', () => {
  const total = 125 * 2;
  assert.equal(total, 250);
});
// This proves the stated arithmetic only, not RLS or persistence.
  1. Claim

    The example checks one calculation and an independent expected value.

  2. Boundary

    No HTTP request, database policy or browser interaction was exercised.

  3. Next proof

    If the claim is 'unauthorized orders cannot be saved', choose a test that reaches the real write authority.

Production thinking

Take this beyond the example.

Test the smallest boundary that can prove each consequential claim. Reserve expensive E2E work for integration/user risks that smaller tests cannot establish; do not replace security integration proof with a mock.

Sources and further reading

Your evidence

unseen is a local learning signal, not a credential or proof of production competence.

Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.

Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.

Next lesson · Make verification reproducible and honest →