Create Test Plan
Overview
Create a structured test plan using the test pyramid (Mike Cohn), boundary value analysis, and risk-based testing. Every test case traces back to an acceptance criterion, covers the right level of the pyramid, and explicitly addresses edge cases and error states.
Workflow
Read project context -- Read .chalk/docs/ for PRDs, user stories, acceptance criteria, and architecture docs. Read existing test plans to understand conventions and coverage gaps.
Determine the next test plan number -- List files in .chalk/docs/engineering/ matching the pattern *_test_plan_*.md. Find the highest number and increment by 1. If none exist, start at 1.
Identify acceptance criteria -- From $ARGUMENTS, conversation context, and project docs, extract every acceptance criterion or expected behavior. If no formal acceptance criteria exist, derive them from the feature description and confirm with the user.
Map criteria to test pyramid levels -- For each acceptance criterion, determine the appropriate test level:
- Unit: Pure logic, calculations, data transformations, validation rules
- Integration: Component interactions, API contracts, database queries, external service calls
- E2E: Critical user journeys, cross-feature workflows, deployment verification
Generate test cases per criterion -- For each acceptance criterion, write specific test cases at the appropriate pyramid level. Include:
- Happy path (expected inputs produce expected outputs)
- Boundary values (edges of valid input ranges)
- Error states (invalid inputs, missing data, system failures)
- Concurrent/race conditions (if applicable)
Identify edge cases -- Systematically generate edge case tests using boundary value analysis:
- Null/empty/missing inputs
- Minimum and maximum valid values
- Values just inside and outside boundaries
- Special characters, unicode, extremely long strings
- Concurrent access and race conditions
- Network failures, timeouts, partial responses
Classify manual vs. automated -- Mark each test case as automated or manual. Default to automated. Manual testing is reserved for:
- Visual/UX verification that cannot be reliably automated
- Exploratory testing for complex user flows
- Accessibility testing requiring human judgment
- Third-party integration testing in sandbox environments
Assign priority tags -- Tag each test case:
- Smoke: Must pass for any deploy -- critical path, data integrity, authentication
- Regression: Run on every PR -- core functionality, important edge cases
- Full: Run before releases -- comprehensive coverage including rare edge cases
Write the file -- Save to .chalk/docs/engineering/<n>_test_plan_<feature_slug>.md.
Confirm -- Tell the user the test plan was created with its path, total test case count, pyramid distribution, and any gaps or risks identified.
Filename Convention
<number>_test_plan_<snake_case_feature>.md
Examples:
4_test_plan_user_registration.md
6_test_plan_checkout_flow.md
11_test_plan_api_rate_limiting.md
Test Plan Format
# Test Plan: <Feature or Component>
Last updated: <YYYY-MM-DD>
## Scope
<What is being tested. Link to PRD, user story, or acceptance criteria document.
State what is in scope and out of scope for this test plan.>
## Acceptance Criteria Reference
| ID | Acceptance Criterion | Source |
|----|---------------------|--------|
| AC-1 | <Criterion text> | <PRD/Story link or "derived"> |
| AC-2 | <Criterion text> | <PRD/Story link or "derived"> |
| AC-3 | <Criterion text> | <PRD/Story link or "derived"> |
## Test Pyramid Distribution
| Level | Count | Percentage |
|-------|-------|------------|
| Unit | <n> | <x%> |
| Integration | <n> | <x%> |
| E2E | <n> | <x%> |
| Manual | <n> | <x%> |
| **Total** | **<n>** | **100%** |
Target distribution: ~70% unit, ~20% integration, ~10% e2e. Deviations noted below.
## Unit Tests
### AC-1: <Criterion summary>
| ID | Test Case | Input | Expected Output | Priority | Type |
|----|-----------|-------|-----------------|----------|------|
| U-1.1 | <Happy path description> | <input> | <output> | Smoke | Auto |
| U-1.2 | <Boundary value> | <input> | <output> | Regression | Auto |
| U-1.3 | <Error case> | <input> | <error/behavior> | Regression | Auto |
### AC-2: <Criterion summary>
| ID | Test Case | Input | Expected Output | Priority | Type |
|----|-----------|-------|-----------------|----------|------|
| U-2.1 | ... | ... | ... | ... | ... |
## Integration Tests
### AC-1: <Criterion summary>
| ID | Test Case | Setup | Action | Expected Result | Priority | Type |
|----|-----------|-------|--------|-----------------|----------|------|
| I-1.1 | <Description> | <preconditions> | <action> | <result> | Smoke | Auto |
| I-1.2 | <Description> | <preconditions> | <action> | <result> | Regression | Auto |
## E2E Tests
| ID | User Journey | Steps | Expected Result | Priority | Type |
|----|-------------|-------|-----------------|----------|------|
| E-1 | <Journey name> | 1. <step> 2. <step> 3. <step> | <result> | Smoke | Auto |
| E-2 | <Journey name> | 1. <step> 2. <step> | <result> | Regression | Auto |
## Edge Case Tests
| ID | Category | Test Case | Input | Expected Behavior | Level | Priority |
|----|----------|-----------|-------|--------------------|-------|----------|
| EC-1 | Null/Empty | <description> | `null` | <behavior> | Unit | Regression |
| EC-2 | Boundary | <description> | <boundary value> | <behavior> | Unit | Regression |
| EC-3 | Concurrency | <description> | <scenario> | <behavior> | Integration | Full |
| EC-4 | Error State | <description> | <failure scenario> | <behavior> | Integration | Regression |
## Manual Tests
| ID | Test Case | Steps | Expected Result | Priority | Why Manual |
|----|-----------|-------|-----------------|----------|------------|
| M-1 | <Description> | 1. <step> 2. <step> | <result> | Full | <reason automation is insufficient> |
## Test Data Requirements
<Describe any test fixtures, seed data, mock services, or environment setup needed.>
## Risks and Gaps
| Risk | Impact | Mitigation |
|------|--------|------------|
| <Testing gap or risk> | <What could go wrong> | <How to address it> |
Content Guidelines
Test Pyramid Distribution
The test pyramid (Mike Cohn) dictates the ideal distribution:
/ E2E \ ~10% - Slow, expensive, brittle
/----------\
/ Integration \ ~20% - Moderate speed, tests boundaries
/----------------\
/ Unit \ ~70% - Fast, cheap, focused
/--------------------\
If your test plan inverts this pyramid (more E2E than unit tests), stop and restructure. Common reasons for inversion and how to fix:
| Problem |
Fix |
| Business logic tested through UI |
Extract logic into testable functions, unit test them |
| API validation tested via E2E |
Write integration tests against the API directly |
| Database logic tested via full stack |
Write integration tests with a test database |
Boundary Value Analysis
For every input that has a range, test these values:
| Input Type |
Test Values |
| Numeric (min: 1, max: 100) |
0, 1, 2, 50, 99, 100, 101 |
| String (max: 255 chars) |
empty, 1 char, 254 chars, 255 chars, 256 chars |
| Array (max: 10 items) |
empty, 1 item, 9 items, 10 items, 11 items |
| Date range |
start-1, start, start+1, end-1, end, end+1 |
| Enum/set |
each valid value, invalid value, null |
Risk-Based Test Prioritization
Assign priority based on two dimensions:
|
High Likelihood of Failure |
Low Likelihood of Failure |
| High Impact |
Smoke -- test on every deploy |
Regression -- test on every PR |
| Low Impact |
Regression -- test on every PR |
Full -- test before release |
High impact includes: data corruption, security breach, financial loss, user-facing errors.
High likelihood includes: new code, complex logic, external dependencies, recently changed areas.
Writing Good Test Cases
Each test case must be:
- Specific: "User with expired session token receives 401 and redirect to login" not "Test authentication"
- Independent: No test should depend on another test's execution or side effects
- Traceable: Every test links back to an acceptance criterion (the AC-X reference)
- Deterministic: Same input always produces same result. No flaky tests. If testing async behavior, define explicit wait conditions.
When to Use Manual Testing
Automated testing is the default. Use manual testing only when:
- Visual appearance must be verified by a human (layout, animations, color accuracy)
- Exploratory testing is needed to find unknown unknowns in complex workflows
- Accessibility requires human judgment (screen reader experience, cognitive load)
- Third-party sandbox environments don't support automation
- The cost of automating exceeds the cost of periodic manual execution
Always document why a test is manual so it can be reconsidered for automation later.
Anti-patterns
- Only testing the happy path: If your test plan has no error cases, boundary tests, or null input tests, it will miss the bugs that actually ship to production. Every acceptance criterion needs at least one sad path test.
- No edge cases: Bugs cluster at boundaries. If you have a numeric input with a range, test the edges. If you accept strings, test empty strings, unicode, and max length. Systematic boundary value analysis catches the defects that "it works on my machine" misses.
- Inverted test pyramid: If most tests are E2E and few are unit tests, the test suite will be slow, flaky, and expensive to maintain. Push tests down to the lowest level that can verify the behavior. E2E tests should only cover critical user journeys, not individual validation rules.
- Not linking tests to acceptance criteria: Tests without traceability to requirements create two problems: you can't verify coverage (are all criteria tested?) and you can't assess impact (if this test fails, what requirement is broken?). Every test must reference an AC.
- Testing implementation details instead of behavior: Tests like "verify the cache map has 3 entries" break when you refactor. Test the observable behavior: "second call returns the same result in under 5ms." Tests should describe what the system does, not how it does it internally.
- All tests marked as Smoke priority: If everything is critical, nothing is. Smoke tests should be a small subset (10-15%) that gates deployment. Over-tagging as Smoke slows down deploys and causes alert fatigue.
- Missing test data documentation: Test plans that assume data exists without specifying it lead to flaky tests and environment-dependent failures. Document what fixtures, seed data, and mocks are needed.
- No concurrency or error state coverage: If the feature handles concurrent users, network calls, or external services, the test plan must include tests for race conditions, timeouts, and partial failures. These are the bugs that cause production incidents.
1---2name: create-test-plan3description: Create a test plan when the user asks to plan testing, define test cases, create a QA strategy, write a test plan, or prepare for testing a feature4---5
6# Create Test Plan
7
8## Overview
9
10Create a structured test plan using the test pyramid (Mike Cohn), boundary value analysis, and risk-based testing. Every test case traces back to an acceptance criterion, covers the right level of the pyramid, and explicitly addresses edge cases and error states.
11
12## Workflow
13
141. **Read project context** -- Read `.chalk/docs/` for PRDs, user stories, acceptance criteria, and architecture docs. Read existing test plans to understand conventions and coverage gaps.
15
162. **Determine the next test plan number** -- List files in `.chalk/docs/engineering/` matching the pattern `*_test_plan_*.md`. Find the highest number and increment by 1. If none exist, start at `1`.
17
183. **Identify acceptance criteria** -- From `$ARGUMENTS`, conversation context, and project docs, extract every acceptance criterion or expected behavior. If no formal acceptance criteria exist, derive them from the feature description and confirm with the user.
19
204. **Map criteria to test pyramid levels** -- For each acceptance criterion, determine the appropriate test level:
21 - **Unit**: Pure logic, calculations, data transformations, validation rules
22 - **Integration**: Component interactions, API contracts, database queries, external service calls
23 - **E2E**: Critical user journeys, cross-feature workflows, deployment verification
24
255. **Generate test cases per criterion** -- For each acceptance criterion, write specific test cases at the appropriate pyramid level. Include:
26 - Happy path (expected inputs produce expected outputs)
27 - Boundary values (edges of valid input ranges)
28 - Error states (invalid inputs, missing data, system failures)
29 - Concurrent/race conditions (if applicable)
30
316. **Identify edge cases** -- Systematically generate edge case tests using boundary value analysis:
32 - Null/empty/missing inputs
33 - Minimum and maximum valid values
34 - Values just inside and outside boundaries
35 - Special characters, unicode, extremely long strings
36 - Concurrent access and race conditions
37 - Network failures, timeouts, partial responses
38
397. **Classify manual vs. automated** -- Mark each test case as automated or manual. Default to automated. Manual testing is reserved for:
40 - Visual/UX verification that cannot be reliably automated
41 - Exploratory testing for complex user flows
42 - Accessibility testing requiring human judgment
43 - Third-party integration testing in sandbox environments
44
458. **Assign priority tags** -- Tag each test case:
46 - **Smoke**: Must pass for any deploy -- critical path, data integrity, authentication
47 - **Regression**: Run on every PR -- core functionality, important edge cases
48 - **Full**: Run before releases -- comprehensive coverage including rare edge cases
49
509. **Write the file** -- Save to `.chalk/docs/engineering/<n>_test_plan_<feature_slug>.md`.
51
5210. **Confirm** -- Tell the user the test plan was created with its path, total test case count, pyramid distribution, and any gaps or risks identified.
53
54## Filename Convention
55
56```
57<number>_test_plan_<snake_case_feature>.md
58```
59
60Examples:
61- `4_test_plan_user_registration.md`
62- `6_test_plan_checkout_flow.md`
63- `11_test_plan_api_rate_limiting.md`
64
65## Test Plan Format
66
67```markdown
68# Test Plan: <Feature or Component>
69
70Last updated: <YYYY-MM-DD>
71
72## Scope
73
74<What is being tested. Link to PRD, user story, or acceptance criteria document.
75State what is in scope and out of scope for this test plan.>
76
77## Acceptance Criteria Reference
78
79| ID | Acceptance Criterion | Source |
80|----|---------------------|--------|
81| AC-1 | <Criterion text> | <PRD/Story link or "derived"> |
82| AC-2 | <Criterion text> | <PRD/Story link or "derived"> |
83| AC-3 | <Criterion text> | <PRD/Story link or "derived"> |
84
85## Test Pyramid Distribution
86
87| Level | Count | Percentage |
88|-------|-------|------------|
89| Unit | <n> | <x%> |
90| Integration | <n> | <x%> |
91| E2E | <n> | <x%> |
92| Manual | <n> | <x%> |
93| **Total** | **<n>** | **100%** |
94
95Target distribution: ~70% unit, ~20% integration, ~10% e2e. Deviations noted below.
96
97## Unit Tests
98
99### AC-1: <Criterion summary>
100
101| ID | Test Case | Input | Expected Output | Priority | Type |
102|----|-----------|-------|-----------------|----------|------|
103| U-1.1 | <Happy path description> | <input> | <output> | Smoke | Auto |
104| U-1.2 | <Boundary value> | <input> | <output> | Regression | Auto |
105| U-1.3 | <Error case> | <input> | <error/behavior> | Regression | Auto |
106
107### AC-2: <Criterion summary>
108
109| ID | Test Case | Input | Expected Output | Priority | Type |
110|----|-----------|-------|-----------------|----------|------|
111| U-2.1 | ... | ... | ... | ... | ... |
112
113## Integration Tests
114
115### AC-1: <Criterion summary>
116
117| ID | Test Case | Setup | Action | Expected Result | Priority | Type |
118|----|-----------|-------|--------|-----------------|----------|------|
119| I-1.1 | <Description> | <preconditions> | <action> | <result> | Smoke | Auto |
120| I-1.2 | <Description> | <preconditions> | <action> | <result> | Regression | Auto |
121
122## E2E Tests
123
124| ID | User Journey | Steps | Expected Result | Priority | Type |
125|----|-------------|-------|-----------------|----------|------|
126| E-1 | <Journey name> | 1. <step> 2. <step> 3. <step> | <result> | Smoke | Auto |
127| E-2 | <Journey name> | 1. <step> 2. <step> | <result> | Regression | Auto |
128
129## Edge Case Tests
130
131| ID | Category | Test Case | Input | Expected Behavior | Level | Priority |
132|----|----------|-----------|-------|--------------------|-------|----------|
133| EC-1 | Null/Empty | <description> | `null` | <behavior> | Unit | Regression |
134| EC-2 | Boundary | <description> | <boundary value> | <behavior> | Unit | Regression |
135| EC-3 | Concurrency | <description> | <scenario> | <behavior> | Integration | Full |
136| EC-4 | Error State | <description> | <failure scenario> | <behavior> | Integration | Regression |
137
138## Manual Tests
139
140| ID | Test Case | Steps | Expected Result | Priority | Why Manual |
141|----|-----------|-------|-----------------|----------|------------|
142| M-1 | <Description> | 1. <step> 2. <step> | <result> | Full | <reason automation is insufficient> |
143
144## Test Data Requirements
145
146<Describe any test fixtures, seed data, mock services, or environment setup needed.>
147
148## Risks and Gaps
149
150| Risk | Impact | Mitigation |
151|------|--------|------------|
152| <Testing gap or risk> | <What could go wrong> | <How to address it> |
153```
154
155## Content Guidelines
156
157### Test Pyramid Distribution
158
159The test pyramid (Mike Cohn) dictates the ideal distribution:
160
161```
162 / E2E \ ~10% - Slow, expensive, brittle
163 /----------\
164 / Integration \ ~20% - Moderate speed, tests boundaries
165 /----------------\
166 / Unit \ ~70% - Fast, cheap, focused
167 /--------------------\
168```
169
170If your test plan inverts this pyramid (more E2E than unit tests), stop and restructure. Common reasons for inversion and how to fix:
171
172| Problem | Fix |
173|---------|-----|
174| Business logic tested through UI | Extract logic into testable functions, unit test them |
175| API validation tested via E2E | Write integration tests against the API directly |
176| Database logic tested via full stack | Write integration tests with a test database |
177
178### Boundary Value Analysis
179
180For every input that has a range, test these values:
181
182| Input Type | Test Values |
183|------------|-------------|
184| Numeric (min: 1, max: 100) | 0, 1, 2, 50, 99, 100, 101 |
185| String (max: 255 chars) | empty, 1 char, 254 chars, 255 chars, 256 chars |
186| Array (max: 10 items) | empty, 1 item, 9 items, 10 items, 11 items |
187| Date range | start-1, start, start+1, end-1, end, end+1 |
188| Enum/set | each valid value, invalid value, null |
189
190### Risk-Based Test Prioritization
191
192Assign priority based on two dimensions:
193
194| | High Likelihood of Failure | Low Likelihood of Failure |
195|---|---|---|
196| **High Impact** | **Smoke** -- test on every deploy | **Regression** -- test on every PR |
197| **Low Impact** | **Regression** -- test on every PR | **Full** -- test before release |
198
199High impact includes: data corruption, security breach, financial loss, user-facing errors.
200High likelihood includes: new code, complex logic, external dependencies, recently changed areas.
201
202### Writing Good Test Cases
203
204Each test case must be:
205- **Specific**: "User with expired session token receives 401 and redirect to login" not "Test authentication"
206- **Independent**: No test should depend on another test's execution or side effects
207- **Traceable**: Every test links back to an acceptance criterion (the AC-X reference)
208- **Deterministic**: Same input always produces same result. No flaky tests. If testing async behavior, define explicit wait conditions.
209
210### When to Use Manual Testing
211
212Automated testing is the default. Use manual testing only when:
213- Visual appearance must be verified by a human (layout, animations, color accuracy)
214- Exploratory testing is needed to find unknown unknowns in complex workflows
215- Accessibility requires human judgment (screen reader experience, cognitive load)
216- Third-party sandbox environments don't support automation
217- The cost of automating exceeds the cost of periodic manual execution
218
219Always document *why* a test is manual so it can be reconsidered for automation later.
220
221## Anti-patterns
222
223- **Only testing the happy path**: If your test plan has no error cases, boundary tests, or null input tests, it will miss the bugs that actually ship to production. Every acceptance criterion needs at least one sad path test.
224- **No edge cases**: Bugs cluster at boundaries. If you have a numeric input with a range, test the edges. If you accept strings, test empty strings, unicode, and max length. Systematic boundary value analysis catches the defects that "it works on my machine" misses.
225- **Inverted test pyramid**: If most tests are E2E and few are unit tests, the test suite will be slow, flaky, and expensive to maintain. Push tests down to the lowest level that can verify the behavior. E2E tests should only cover critical user journeys, not individual validation rules.
226- **Not linking tests to acceptance criteria**: Tests without traceability to requirements create two problems: you can't verify coverage (are all criteria tested?) and you can't assess impact (if this test fails, what requirement is broken?). Every test must reference an AC.
227- **Testing implementation details instead of behavior**: Tests like "verify the cache map has 3 entries" break when you refactor. Test the observable behavior: "second call returns the same result in under 5ms." Tests should describe *what* the system does, not *how* it does it internally.
228- **All tests marked as Smoke priority**: If everything is critical, nothing is. Smoke tests should be a small subset (10-15%) that gates deployment. Over-tagging as Smoke slows down deploys and causes alert fatigue.
229- **Missing test data documentation**: Test plans that assume data exists without specifying it lead to flaky tests and environment-dependent failures. Document what fixtures, seed data, and mocks are needed.
230- **No concurrency or error state coverage**: If the feature handles concurrent users, network calls, or external services, the test plan must include tests for race conditions, timeouts, and partial failures. These are the bugs that cause production incidents.