Improving Testing
When to Use
Use when user asks:
- "What should I test for this feature?"
- "How do I test edge cases?"
- "Review my tests"
- "What cases am I missing?"
- "Help me pick test cases"
- "How to test validation/permissions/state machines?"
Do NOT Use When
- User wants to run existing tests (use terminal)
- User wants test code generation without design planning
- User asks about test framework setup or tooling
- User asks about CI/CD pipeline configuration
Inputs (ask if missing)
- Feature in one sentence
- Biggest risks (user harm, money, trust, security)
- Inputs and constraints (types, ranges, formats)
- Roles and permissions
- States and transitions
If unknown, assume and state assumptions.
Workflow
Step 1: Define the goal
Pick the primary goal:
- Verify requirement
- Document behavior
- Prevent regressions in risky areas
Step 2: Identify risks
List 3 to 7 risks. Prefer:
- Permissions, security, privacy
- Money and data integrity
- Complex branching logic
- Stateful behavior
- Boundary and validation failures
Step 3: Design cases before writing tests
Pick the technique that matches the problem:
- Equivalence classes: representative per group
- Boundary values: min, max, just below, just above
- Decision table: combinations of conditions
- State transitions: allowed and forbidden transitions
For each rule, include:
- One positive case
- One negative case
- One edge case (boundary, empty, null, max length, weird chars)
Write each test idea as:
- Preconditions
- Inputs
- Action
- Expected result (oracle)
Step 4: Plan test data
For each case, define representative data:
- One value per equivalence class
- Boundary values for ranges and lengths
- Clearly named examples (avoid random data)
Step 5: Review and harden the tests
Check each test for:
- Correctness: matches requirement and risk
- Strength: fails for the right reason
- Relevance: covers risky paths, not only happy path
- Determinism: no time, randomness, network, ordering leaks
- Maintainability: clear setup, focused assertions, minimal noise
- Gaps: which risks have zero tests?
- Redundancy: which tests repeat the same behavior?
Never weaken assertions just to make the test pass. Fix the code or redesign the test.
Step 6: Coverage guidance
- Line coverage is a baseline
- Prefer decision or branch coverage for branching logic
- Raise coverage mainly in high risk areas
Output Format
- Rules applied
- Mini test plan
- Smallest useful set of cases
- Review notes (only if tests provided)
- Bug report (only if failure reported)
Rules Checklist
Start with risk. Test what could hurt users, money, or trust.
Write the test idea before the test code. A sentence like: "If X, then Y, because Z risk."
Always include: positive, negative, edge. Do not stop at happy path.
Use partitions and boundaries. Pick one representative per group, then test edges.
When conditions combine, use a decision table. Map the combinations, then pick the smallest set that covers the rules.
When behavior changes by state, test transitions. Test one allowed and one forbidden transition.
One test, one point. Split mixed tests.
Name tests by behavior. Use "when ... it ..." naming.
Assert outcomes, not steps. Prefer results and side effects over internal calls.
Keep tests deterministic. Avoid time, randomness, network calls, and order dependence.
Regularly check gaps and redundancy. Add missing tests for risky rules. Remove duplicates that prove the same thing.
Examples
Example 1: Validation with boundaries
Rules applied:
- Always include: positive, negative, edge
- Test the edges first
Mini test plan:
- Feature: User age must be 18+
- Risks: underage access, off-by-one bug
- Technique: Boundary values
Smallest useful set of cases:
| Input |
Expected |
Type |
| age 18 |
accepted |
positive |
| age 17 |
rejected |
negative |
| age missing |
rejected |
edge |
Review notes:
Assert the validation error, not a generic success response.
Example 2: Permissions with roles
Rules applied:
- Test risky actions (delete, refund, export)
- Use a small decision table
Mini test plan:
- Feature: Only admins can delete posts
- Risks: unauthorized data loss
- Technique: Decision table (role x action)
Smallest useful set of cases:
| Actor |
Action |
Expected |
Type |
| admin |
delete |
allowed |
positive |
| non-admin |
delete |
forbidden |
negative |
| unauthenticated |
delete |
forbidden |
edge |
Review notes:
Assert status and side effect (record removed), not internal method calls.
Example 3: Combined conditions (decision table)
Rules applied:
- Map combinations, do not guess
- Assert the final outcome
Mini test plan:
- Feature: Discount applies when (member AND cart >= 100) OR promo_code valid
- Risks: wrong price charged
- Technique: Decision table
Smallest useful set of cases:
| Member |
Cart |
Promo |
Expected |
Type |
| yes |
100 |
- |
discount |
positive |
| yes |
99 |
- |
no discount |
edge |
| no |
20 |
valid |
discount |
positive |
| no |
200 |
invalid |
no discount |
negative |
Review notes:
Assert final price, not intermediate flags.
Example 4: State transitions
Rules applied:
- Test one allowed and one forbidden transition
- State bugs are common regressions
Mini test plan:
- Feature: Invoice can be paid only if issued
- Risks: invalid financial state
- Technique: State transitions
Smallest useful set of cases:
| From State |
Action |
Expected |
Type |
| issued |
pay |
allowed |
positive |
| draft |
pay |
forbidden |
negative |
| paid |
pay again |
forbidden |
edge |
Review notes:
Assert final state and single payment record.
Example 5: Bug report format
When user reports a failure, produce a bug report:
Title: [Brief description]
Environment: [OS, browser, version]
Preconditions: [Required state before reproducing]
Steps to reproduce:
1. ...
2. ...
Expected result: [What should happen]
Actual result: [What actually happened]
Severity: [Critical/High/Medium/Low]
Notes / logs: [Relevant error messages or logs]
1---2name: improving-testing3description: Produces practical, risk-based testing guidance and minimal test plans for features or changes. Use when user asks what to test, how to pick test cases (boundaries, permissions, state machines), how to improve weak tests, or to review existing tests. Covers equivalence partitions, boundary values, decision tables, and state transitions.4---56# Improving Testing78## When to Use9Use when user asks:10- "What should I test for this feature?"11- "How do I test edge cases?"12- "Review my tests"13- "What cases am I missing?"14- "Help me pick test cases"15- "How to test validation/permissions/state machines?"1617## Do NOT Use When18- User wants to run existing tests (use terminal)19- User wants test code generation without design planning20- User asks about test framework setup or tooling21- User asks about CI/CD pipeline configuration2223## Inputs (ask if missing)24- Feature in one sentence25- Biggest risks (user harm, money, trust, security)26- Inputs and constraints (types, ranges, formats)27- Roles and permissions28- States and transitions2930If unknown, assume and state assumptions.3132## Workflow3334### Step 1: Define the goal35Pick the primary goal:36- Verify requirement37- Document behavior38- Prevent regressions in risky areas3940### Step 2: Identify risks41List 3 to 7 risks. Prefer:42- Permissions, security, privacy43- Money and data integrity44- Complex branching logic45- Stateful behavior46- Boundary and validation failures4748### Step 3: Design cases before writing tests49Pick the technique that matches the problem:50- **Equivalence classes**: representative per group51- **Boundary values**: min, max, just below, just above52- **Decision table**: combinations of conditions53- **State transitions**: allowed and forbidden transitions5455For each rule, include:56- One positive case57- One negative case58- One edge case (boundary, empty, null, max length, weird chars)5960Write each test idea as:61- Preconditions62- Inputs63- Action64- Expected result (oracle)6566### Step 4: Plan test data67For each case, define representative data:68- One value per equivalence class69- Boundary values for ranges and lengths70- Clearly named examples (avoid random data)7172### Step 5: Review and harden the tests73Check each test for:74- **Correctness**: matches requirement and risk75- **Strength**: fails for the right reason76- **Relevance**: covers risky paths, not only happy path77- **Determinism**: no time, randomness, network, ordering leaks78- **Maintainability**: clear setup, focused assertions, minimal noise79- **Gaps**: which risks have zero tests?80- **Redundancy**: which tests repeat the same behavior?8182Never weaken assertions just to make the test pass. Fix the code or redesign the test.8384### Step 6: Coverage guidance85- Line coverage is a baseline86- Prefer decision or branch coverage for branching logic87- Raise coverage mainly in high risk areas8889## Output Format901. Rules applied912. Mini test plan923. Smallest useful set of cases934. Review notes (only if tests provided)945. Bug report (only if failure reported)9596## Rules Checklist97981. **Start with risk.** Test what could hurt users, money, or trust.991002. **Write the test idea before the test code.** A sentence like: "If X, then Y, because Z risk."1011023. **Always include: positive, negative, edge.** Do not stop at happy path.1031044. **Use partitions and boundaries.** Pick one representative per group, then test edges.1051065. **When conditions combine, use a decision table.** Map the combinations, then pick the smallest set that covers the rules.1071086. **When behavior changes by state, test transitions.** Test one allowed and one forbidden transition.1091107. **One test, one point.** Split mixed tests.1111128. **Name tests by behavior.** Use "when ... it ..." naming.1131149. **Assert outcomes, not steps.** Prefer results and side effects over internal calls.11511610. **Keep tests deterministic.** Avoid time, randomness, network calls, and order dependence.11711811. **Regularly check gaps and redundancy.** Add missing tests for risky rules. Remove duplicates that prove the same thing.119120## Examples121122### Example 1: Validation with boundaries123124**Rules applied:**125- Always include: positive, negative, edge126- Test the edges first127128**Mini test plan:**129- Feature: User age must be 18+130- Risks: underage access, off-by-one bug131- Technique: Boundary values132133**Smallest useful set of cases:**134| Input | Expected | Type |135|-------|----------|------|136| age 18 | accepted | positive |137| age 17 | rejected | negative |138| age missing | rejected | edge |139140**Review notes:**141Assert the validation error, not a generic success response.142143---144145### Example 2: Permissions with roles146147**Rules applied:**148- Test risky actions (delete, refund, export)149- Use a small decision table150151**Mini test plan:**152- Feature: Only admins can delete posts153- Risks: unauthorized data loss154- Technique: Decision table (role x action)155156**Smallest useful set of cases:**157| Actor | Action | Expected | Type |158|-------|--------|----------|------|159| admin | delete | allowed | positive |160| non-admin | delete | forbidden | negative |161| unauthenticated | delete | forbidden | edge |162163**Review notes:**164Assert status and side effect (record removed), not internal method calls.165166---167168### Example 3: Combined conditions (decision table)169170**Rules applied:**171- Map combinations, do not guess172- Assert the final outcome173174**Mini test plan:**175- Feature: Discount applies when (member AND cart >= 100) OR promo_code valid176- Risks: wrong price charged177- Technique: Decision table178179**Smallest useful set of cases:**180| Member | Cart | Promo | Expected | Type |181|--------|------|-------|----------|------|182| yes | 100 | - | discount | positive |183| yes | 99 | - | no discount | edge |184| no | 20 | valid | discount | positive |185| no | 200 | invalid | no discount | negative |186187**Review notes:**188Assert final price, not intermediate flags.189190---191192### Example 4: State transitions193194**Rules applied:**195- Test one allowed and one forbidden transition196- State bugs are common regressions197198**Mini test plan:**199- Feature: Invoice can be paid only if issued200- Risks: invalid financial state201- Technique: State transitions202203**Smallest useful set of cases:**204| From State | Action | Expected | Type |205|------------|--------|----------|------|206| issued | pay | allowed | positive |207| draft | pay | forbidden | negative |208| paid | pay again | forbidden | edge |209210**Review notes:**211Assert final state and single payment record.212213---214215### Example 5: Bug report format216217When user reports a failure, produce a bug report:218219```220Title: [Brief description]221Environment: [OS, browser, version]222Preconditions: [Required state before reproducing]223Steps to reproduce:224 1. ...225 2. ...226Expected result: [What should happen]227Actual result: [What actually happened]228Severity: [Critical/High/Medium/Low]229Notes / logs: [Relevant error messages or logs]230```