High-Value Tests
Protect the changed behavior with the fewest tests that give useful confidence.
Test count is not a goal.
Choose the Coverage
- Read the change, existing tests, and repository test guidance before writing
tests.
- Name the primary user path and the real risks introduced or changed by the
work.
- Keep one strong test for the primary user path by default. Extend an existing
test when it can cover the behavior without making the failure unclear.
- Add another test only when it protects a distinct risk, such as:
- a materially different branch or failure mode;
- permissions, security, privacy, or data integrity;
- idempotency or a state transition;
- an external API or persisted-data contract;
- a boundary condition with a credible failure;
- a regression that the primary-path test does not detect.
For each additional test, complete: This test protects X from Y. If the answer
is the same as another test, merge or remove the duplicate.
Use the Right Test Layer
- Test at the smallest layer that observes the contract. Do not repeat the same
risk at unit, API, integration, and end-to-end layers.
- Exercise the real application path. Mock external I/O boundaries, not the
application method under test.
- Keep assertions on required boundary calls and arguments when the call is the
observable behavior, such as queuing a task or sending an event.
- Prefer existing factories, helpers, and parameterization over repeated setup
and near-identical test functions.
- Assert behavior and contracts. Do not test framework behavior, constants, or
implementation details unless the change depends on them.
Remove or Flag Low-Value Cases
When writing or editing tests, remove or combine the cases below. During a
review, report them as findings and do not edit files unless the user asks for
changes.
- repeat the same behavior with values that do not change the result;
- duplicate stronger coverage at another layer;
- only prove that internal mocks were called without verifying an observable
contract;
- patch away the code path that they claim to test;
- add one test per field or branch when one focused or parameterized test is
clearer;
- cannot identify a distinct failure that they would catch.
Do not remove required security, privacy, data-integrity, API-contract, or known
regression coverage to reduce test time. Follow explicit repository or user
requirements when they require broader coverage.
Report the Result
Run the smallest relevant test command for the tests you changed. If it cannot
run, state the command and the reason instead of claiming verified coverage.
Summarize the behaviors and risks covered. If you remove or skip likely test
cases, state which ones and why their coverage is duplicate or low value.
1---2name: high-value-tests3description: Write or review the smallest test set that gives useful confidence in a code change. Use when adding, generating, or reviewing tests, especially when agent-generated tests may duplicate coverage or add low-value cases.4license: MIT5---67# High-Value Tests89Protect the changed behavior with the fewest tests that give useful confidence.10Test count is not a goal.1112## Choose the Coverage13141. Read the change, existing tests, and repository test guidance before writing15 tests.162. Name the primary user path and the real risks introduced or changed by the17 work.183. Keep one strong test for the primary user path by default. Extend an existing19 test when it can cover the behavior without making the failure unclear.204. Add another test only when it protects a distinct risk, such as:21 - a materially different branch or failure mode;22 - permissions, security, privacy, or data integrity;23 - idempotency or a state transition;24 - an external API or persisted-data contract;25 - a boundary condition with a credible failure;26 - a regression that the primary-path test does not detect.2728For each additional test, complete: `This test protects X from Y.` If the answer29is the same as another test, merge or remove the duplicate.3031## Use the Right Test Layer3233- Test at the smallest layer that observes the contract. Do not repeat the same34 risk at unit, API, integration, and end-to-end layers.35- Exercise the real application path. Mock external I/O boundaries, not the36 application method under test.37- Keep assertions on required boundary calls and arguments when the call is the38 observable behavior, such as queuing a task or sending an event.39- Prefer existing factories, helpers, and parameterization over repeated setup40 and near-identical test functions.41- Assert behavior and contracts. Do not test framework behavior, constants, or42 implementation details unless the change depends on them.4344## Remove or Flag Low-Value Cases4546When writing or editing tests, remove or combine the cases below. During a47review, report them as findings and do not edit files unless the user asks for48changes.4950- repeat the same behavior with values that do not change the result;51- duplicate stronger coverage at another layer;52- only prove that internal mocks were called without verifying an observable53 contract;54- patch away the code path that they claim to test;55- add one test per field or branch when one focused or parameterized test is56 clearer;57- cannot identify a distinct failure that they would catch.5859Do not remove required security, privacy, data-integrity, API-contract, or known60regression coverage to reduce test time. Follow explicit repository or user61requirements when they require broader coverage.6263## Report the Result6465Run the smallest relevant test command for the tests you changed. If it cannot66run, state the command and the reason instead of claiming verified coverage.6768Summarize the behaviors and risks covered. If you remove or skip likely test69cases, state which ones and why their coverage is duplicate or low value.