Hope Test Strategy
Choose tests that reduce uncertainty about the requested behavior. Test-first is
a valuable technique, not an unconditional law.
Precedence
Follow the user's request and repository instructions. Do not run broad suites,
install dependencies, or rewrite test infrastructure when the project forbids or
does not require it.
Select The Strategy
Test-first
Prefer a failing test before implementation when the new contract is clear, the
test seam is stable, and observing the failure proves the test is meaningful.
Regression-first
For a bug, reproduce the original failure in the narrowest credible automated
test before or alongside the fix. Confirm it fails for the right reason, then
passes after the root-cause change.
Characterization-first
For legacy, poorly documented, or risky refactors, capture current intentional
behavior before changing structure. Do not freeze a known bug as desired
behavior.
Implementation-first with immediate coverage
Reasonable for exploratory seams, generated code, mechanical migrations, or UI
work where the correct test boundary becomes clear only after a small reversible
implementation. Add the relevant proof before claiming completion.
No new automated test
Reasonable for pure docs, trivial metadata, generated outputs, or low-risk
mechanical changes when existing checks directly cover the risk. Explain the
decision rather than adding a meaningless test.
Choose The Layer
- Unit: pure logic, state transition, parser, policy, or failure classification.
- Integration: persistence, adapter, protocol, or cross-module contract.
- E2E: a user-critical path that only becomes true across the full stack.
- Manual smoke: visual layout, OS integration, credentials, or external state
that cannot be honestly simulated.
Use the lowest layer that proves the contract. Add a higher layer only for a
boundary the lower layer cannot cover.
Test Quality
- Assert observable behavior, not incidental implementation details.
- Keep fixtures deterministic and failures diagnostic.
- Cover the demonstrated edge, including cancellation, retry, stale state, or
partial failure when relevant.
- Avoid mocks that erase the boundary being tested.
- Do not weaken existing assertions merely to make a change pass.
Execute Efficiently
- Run the narrowest new or failing test.
- Run the nearest affected suite when justified.
- Use
ha-verify to decide whether broader gates are needed at closeout.
If a test is flaky or environment-blocked, investigate the cause. Do not rerun
until green and call that proof.
Smoke Prompts
- "Choose and add the right regression test for this bug."
- "Refactor this legacy parser without freezing the broken behavior."
- "Decide whether this UI change needs unit, E2E, or manual evidence."
1---
2name: ha-test-strategy
3description: "Hope-native test strategy for features, fixes, and refactors: select test-first, regression-first, characterization, integration, E2E, or manual evidence according to risk and repository rules."
4paths: ["*.rs", "*.ts", "*.tsx", "*.js", "*.jsx", "*.py", "*.go", "*.java", "*.kt", "*.swift", "*.c", "*.cpp", "*.h", "*.rb", "*.php", "*.sh"]
5---
6
7# Hope Test Strategy
8
9Choose tests that reduce uncertainty about the requested behavior. Test-first is
10a valuable technique, not an unconditional law.
11
12## Precedence
13
14Follow the user's request and repository instructions. Do not run broad suites,
15install dependencies, or rewrite test infrastructure when the project forbids or
16does not require it.
17
18## Select The Strategy
19
20### Test-first
21
22Prefer a failing test before implementation when the new contract is clear, the
23test seam is stable, and observing the failure proves the test is meaningful.
24
25### Regression-first
26
27For a bug, reproduce the original failure in the narrowest credible automated
28test before or alongside the fix. Confirm it fails for the right reason, then
29passes after the root-cause change.
30
31### Characterization-first
32
33For legacy, poorly documented, or risky refactors, capture current intentional
34behavior before changing structure. Do not freeze a known bug as desired
35behavior.
36
37### Implementation-first with immediate coverage
38
39Reasonable for exploratory seams, generated code, mechanical migrations, or UI
40work where the correct test boundary becomes clear only after a small reversible
41implementation. Add the relevant proof before claiming completion.
42
43### No new automated test
44
45Reasonable for pure docs, trivial metadata, generated outputs, or low-risk
46mechanical changes when existing checks directly cover the risk. Explain the
47decision rather than adding a meaningless test.
48
49## Choose The Layer
50
51- Unit: pure logic, state transition, parser, policy, or failure classification.
52- Integration: persistence, adapter, protocol, or cross-module contract.
53- E2E: a user-critical path that only becomes true across the full stack.
54- Manual smoke: visual layout, OS integration, credentials, or external state
55 that cannot be honestly simulated.
56
57Use the lowest layer that proves the contract. Add a higher layer only for a
58boundary the lower layer cannot cover.
59
60## Test Quality
61
62- Assert observable behavior, not incidental implementation details.
63- Keep fixtures deterministic and failures diagnostic.
64- Cover the demonstrated edge, including cancellation, retry, stale state, or
65 partial failure when relevant.
66- Avoid mocks that erase the boundary being tested.
67- Do not weaken existing assertions merely to make a change pass.
68
69## Execute Efficiently
70
711. Run the narrowest new or failing test.
722. Run the nearest affected suite when justified.
733. Use `ha-verify` to decide whether broader gates are needed at closeout.
74
75If a test is flaky or environment-blocked, investigate the cause. Do not rerun
76until green and call that proof.
77
78## Smoke Prompts
79
80- "Choose and add the right regression test for this bug."
81- "Refactor this legacy parser without freezing the broken behavior."
82- "Decide whether this UI change needs unit, E2E, or manual evidence."