R89 Test the behavior a change adds or changes

On by default

When a change adds behavior to code or changes its behavior, add or change in the same change a test that checks the new behavior.

Reason

That the code now does what the change claims needs grounds that someone else can check (Art. VII §1(1)), and a test is such grounds only if it would catch the old behavior (Art. VII §2). Without one, the next change can undo the behavior with every check still passing.

Verification

Behavior is what code does that its callers or users can observe. A change that keeps behavior, such as a refactoring or a change to comments, documents or formatting only, adds none. A test checks the new behavior when it passes with the change and would fail on the code before it; a test that passes both before and after the change does not.

Violated when a merged change adds or changes behavior of code and the same change adds or changes no test that checks the new behavior.

Provisions of the constitution it cites

Relations

Parent
R277 Testing
Requires
none
Conflicts with
none

Metadata

ID
89
Revision
3
Kind
rule
Status
trial
Slug
test-new-and-changed-behavior
Default level
project
Constitution revisions
>=1
Check
none
Default
on
Uses
Instructions instructions, Review review
Original language
English en
Translations
Chinese zh