R252 Test only the happy path and the boundaries the requirements set

Off by default

Apart from a regression test for a bug that occurred, write tests only of what code does on its happy path and at the boundaries its requirements set.

Reason

Every test is code that is run, read and kept up for as long as it stays (Art. III §4). A test of what no caller does and no requirement names fixes behavior nobody needs and adds that cost for nothing.

Verification

The happy path is what the code does with the ordinary input its callers give, as its requirements describe. A boundary the requirements set is an edge or a failure that a requirement, a specification or a record of a bug names: an empty list the code must accept, a limit it must enforce, input from outside that it must reject. Input that is plainly unreasonable, which no caller gives or could be expected to, such as a negative count of files, a path that is a number or a type the signature excludes, is neither. A regression test is one whose purpose is to keep a past failure from coming back; rule 84 governs it.

Violated when a change adds a test, other than a regression test, of what code does off its happy path and at no boundary its requirements set.

Provisions of the constitution it cites

Relations

Parent
R277 Testing
Requires
none
Conflicts with
none

Metadata

ID
252
Revision
2
Kind
rule
Status
trial
Slug
tests-only-happy-path-and-set-boundaries
Default level
project
Constitution revisions
>=1
Check
none
Default
off
Uses
Instructions instructions, Review review
Original language
English en
Translations
Chinese zh