Validate Test Coverage
Overview
Cross-reference acceptance criteria from user stories against existing test cases to identify coverage gaps. This is not about code coverage percentages — it is about whether every requirement has a corresponding test at the appropriate level of the test pyramid, including edge cases and error states.
Workflow
Read project context — Read .chalk/docs/ for:
- User stories with acceptance criteria (
*user_stories*, *prd*, *requirements*)
- Test plans (
*test_plan*)
- Any existing coverage reports (
*test_coverage*)
- Architecture docs for understanding component boundaries
Identify the scope — From $ARGUMENTS and conversation context:
- If a specific feature or user story is named, scope the validation to those criteria
- If no scope is given, validate all acceptance criteria found in
.chalk/docs/
- List every acceptance criterion with its source document and ID
Inventory existing test cases — Scan test plans in .chalk/docs/engineering/ and test files in the codebase:
- Map each test case to the acceptance criterion it covers
- Note the test pyramid level (unit, integration, E2E, manual)
- Note whether the test covers happy path only, or also includes edge cases and error states
Cross-reference criteria to tests — For each acceptance criterion, determine:
- Covered: A test exists for the happy path AND at least one edge case or error state, at the appropriate pyramid level
- Partially Covered: A test exists but only covers the happy path, or exists at the wrong pyramid level (e.g., E2E test for pure logic that should be a unit test)
- Uncovered: No test case maps to this criterion
Identify missing edge cases — For each acceptance criterion, check whether tests exist for:
- Boundary values (min, max, off-by-one)
- Null/empty/missing inputs
- Error states and failure modes
- Concurrent access (if applicable)
- Permission/authorization variations
- If the user story mentions specific edge cases, verify those have explicit tests
Assess pyramid health — Check whether the test distribution follows the pyramid:
- ~70% unit, ~20% integration, ~10% E2E
- Flag inversions where business logic is only tested via E2E
- Flag gaps where integration points have no integration tests
Generate the coverage report — Write the report using the format below. Save to .chalk/docs/engineering/<n>_test_coverage_report.md if requested, or present in conversation.
Confirm — Summarize findings: total criteria count, covered/partially covered/uncovered counts, and the most critical gaps.
Filename Convention
<number>_test_coverage_report.md
Examples:
7_test_coverage_report.md
12_test_coverage_report.md
Coverage Report Format
# Test Coverage Report
Last updated: <YYYY-MM-DD>
## Summary
| Metric | Count | Percentage |
|--------|-------|------------|
| Total Acceptance Criteria | <n> | 100% |
| Fully Covered | <n> | <x%> |
| Partially Covered | <n> | <x%> |
| Uncovered | <n> | <x%> |
## Test Pyramid Distribution
| Level | Count | Percentage | Target |
|-------|-------|------------|--------|
| Unit | <n> | <x%> | ~70% |
| Integration | <n> | <x%> | ~20% |
| E2E | <n> | <x%> | ~10% |
## Coverage Detail
### Fully Covered
| AC ID | Criterion | Test IDs | Levels | Edge Cases |
|-------|-----------|----------|--------|------------|
| AC-1 | <criterion text> | U-1.1, U-1.2, I-1.1 | Unit, Integration | Null input, boundary |
### Partially Covered
| AC ID | Criterion | Test IDs | What is Covered | What is Missing |
|-------|-----------|----------|-----------------|-----------------|
| AC-3 | <criterion text> | U-3.1 | Happy path only | Error states, boundary values |
### Uncovered
| AC ID | Criterion | Source | Recommended Level | Priority |
|-------|-----------|--------|-------------------|----------|
| AC-5 | <criterion text> | <PRD/story ref> | Unit | High — data validation |
## Missing Edge Cases
| AC ID | Edge Case Category | Description | Recommended Test |
|-------|-------------------|-------------|------------------|
| AC-1 | Boundary | Max length input not tested | Unit test with 255-char input |
| AC-2 | Error State | Network timeout not tested | Integration test with mock timeout |
| AC-4 | Concurrency | Simultaneous updates not tested | Integration test with concurrent writes |
## Pyramid Health Issues
<List any pyramid inversions or gaps. For example:>
- **Inversion**: AC-2 (input validation) is only tested via E2E. This logic should have unit tests.
- **Gap**: No integration tests exist for the payment service boundary. API contract changes could break silently.
## Recommendations
1. **Critical** — <uncovered criterion with high user impact>
2. **High** — <partially covered criterion missing error states>
3. **Medium** — <pyramid inversion that should be restructured>
Coverage Classification Rules
Fully Covered
All of the following must be true:
- At least one test exists for the happy path
- At least one test exists for an error or edge case
- Tests are at the appropriate pyramid level (logic = unit, boundaries = integration, journeys = E2E)
- Test assertions verify the correct behavior (not just "no error thrown")
Partially Covered
Any of the following:
- Happy path tested but no edge cases or error states
- Tests exist but at the wrong pyramid level
- Tests exist but assertions are weak (e.g., only checking status code, not response body)
- Only one path through a conditional is tested
Uncovered
- No test maps to this acceptance criterion at any level
- A test exists with a similar name but does not actually verify the criterion's behavior
Content Guidelines
What Counts as an Acceptance Criterion
- Explicit "Given/When/Then" statements in user stories
- "The system shall..." requirements
- Validation rules (e.g., "email must be valid format")
- Business rules (e.g., "discount applies only to orders over $50")
- Non-functional requirements (e.g., "page loads in under 2 seconds")
- Error handling requirements (e.g., "invalid input shows error message")
What Does NOT Count as Coverage
- A test file existing for a module (the tests must actually verify the criterion)
- Code coverage percentage (100% line coverage can still miss acceptance criteria)
- Tests that only exercise code without meaningful assertions
- Tests that verify implementation details rather than behavior
Anti-patterns
- Counting tests instead of checking coverage — 200 unit tests means nothing if 5 acceptance criteria have zero tests. Coverage is about requirements traceability, not test count.
- Ignoring edge case coverage — A criterion marked "covered" because the happy path works, while boundary values, null inputs, and error states are untested. Partial coverage must be flagged honestly.
- Only checking unit test presence — Integration boundaries and E2E user journeys need their own tests. A feature with 50 unit tests but no integration test for the API contract is not fully covered.
- Treating code coverage as test coverage — Code coverage measures which lines were executed, not whether the behavior is correct. A test that calls a function without asserting the result gives you line coverage but zero behavioral coverage.
- Not reading the actual test assertions — A test named
test_user_registration might only check that no exception is thrown, not that the user is actually created with the correct data. Read the assertions, not just the test names.
- Marking derived criteria as uncovered without context — If acceptance criteria were derived (not from a formal document), note that they are derived and flag for product confirmation rather than marking as a gap.
1---2name: validate-test-coverage-23description: Validate test coverage against acceptance criteria when the user asks to check test coverage, verify tests match requirements, audit test completeness, or cross-reference user stories with test cases4---5
6# Validate Test Coverage
7
8## Overview
9
10Cross-reference acceptance criteria from user stories against existing test cases to identify coverage gaps. This is not about code coverage percentages — it is about whether every requirement has a corresponding test at the appropriate level of the test pyramid, including edge cases and error states.
11
12## Workflow
13
141. **Read project context** — Read `.chalk/docs/` for:
15 - User stories with acceptance criteria (`*user_stories*`, `*prd*`, `*requirements*`)
16 - Test plans (`*test_plan*`)
17 - Any existing coverage reports (`*test_coverage*`)
18 - Architecture docs for understanding component boundaries
19
202. **Identify the scope** — From `$ARGUMENTS` and conversation context:
21 - If a specific feature or user story is named, scope the validation to those criteria
22 - If no scope is given, validate all acceptance criteria found in `.chalk/docs/`
23 - List every acceptance criterion with its source document and ID
24
253. **Inventory existing test cases** — Scan test plans in `.chalk/docs/engineering/` and test files in the codebase:
26 - Map each test case to the acceptance criterion it covers
27 - Note the test pyramid level (unit, integration, E2E, manual)
28 - Note whether the test covers happy path only, or also includes edge cases and error states
29
304. **Cross-reference criteria to tests** — For each acceptance criterion, determine:
31 - **Covered**: A test exists for the happy path AND at least one edge case or error state, at the appropriate pyramid level
32 - **Partially Covered**: A test exists but only covers the happy path, or exists at the wrong pyramid level (e.g., E2E test for pure logic that should be a unit test)
33 - **Uncovered**: No test case maps to this criterion
34
355. **Identify missing edge cases** — For each acceptance criterion, check whether tests exist for:
36 - Boundary values (min, max, off-by-one)
37 - Null/empty/missing inputs
38 - Error states and failure modes
39 - Concurrent access (if applicable)
40 - Permission/authorization variations
41 - If the user story mentions specific edge cases, verify those have explicit tests
42
436. **Assess pyramid health** — Check whether the test distribution follows the pyramid:
44 - ~70% unit, ~20% integration, ~10% E2E
45 - Flag inversions where business logic is only tested via E2E
46 - Flag gaps where integration points have no integration tests
47
487. **Generate the coverage report** — Write the report using the format below. Save to `.chalk/docs/engineering/<n>_test_coverage_report.md` if requested, or present in conversation.
49
508. **Confirm** — Summarize findings: total criteria count, covered/partially covered/uncovered counts, and the most critical gaps.
51
52## Filename Convention
53
54```
55<number>_test_coverage_report.md
56```
57
58Examples:
59- `7_test_coverage_report.md`
60- `12_test_coverage_report.md`
61
62## Coverage Report Format
63
64```markdown
65# Test Coverage Report
66
67Last updated: <YYYY-MM-DD>
68
69## Summary
70
71| Metric | Count | Percentage |
72|--------|-------|------------|
73| Total Acceptance Criteria | <n> | 100% |
74| Fully Covered | <n> | <x%> |
75| Partially Covered | <n> | <x%> |
76| Uncovered | <n> | <x%> |
77
78## Test Pyramid Distribution
79
80| Level | Count | Percentage | Target |
81|-------|-------|------------|--------|
82| Unit | <n> | <x%> | ~70% |
83| Integration | <n> | <x%> | ~20% |
84| E2E | <n> | <x%> | ~10% |
85
86## Coverage Detail
87
88### Fully Covered
89
90| AC ID | Criterion | Test IDs | Levels | Edge Cases |
91|-------|-----------|----------|--------|------------|
92| AC-1 | <criterion text> | U-1.1, U-1.2, I-1.1 | Unit, Integration | Null input, boundary |
93
94### Partially Covered
95
96| AC ID | Criterion | Test IDs | What is Covered | What is Missing |
97|-------|-----------|----------|-----------------|-----------------|
98| AC-3 | <criterion text> | U-3.1 | Happy path only | Error states, boundary values |
99
100### Uncovered
101
102| AC ID | Criterion | Source | Recommended Level | Priority |
103|-------|-----------|--------|-------------------|----------|
104| AC-5 | <criterion text> | <PRD/story ref> | Unit | High — data validation |
105
106## Missing Edge Cases
107
108| AC ID | Edge Case Category | Description | Recommended Test |
109|-------|-------------------|-------------|------------------|
110| AC-1 | Boundary | Max length input not tested | Unit test with 255-char input |
111| AC-2 | Error State | Network timeout not tested | Integration test with mock timeout |
112| AC-4 | Concurrency | Simultaneous updates not tested | Integration test with concurrent writes |
113
114## Pyramid Health Issues
115
116<List any pyramid inversions or gaps. For example:>
117- **Inversion**: AC-2 (input validation) is only tested via E2E. This logic should have unit tests.
118- **Gap**: No integration tests exist for the payment service boundary. API contract changes could break silently.
119
120## Recommendations
121
1221. **Critical** — <uncovered criterion with high user impact>
1232. **High** — <partially covered criterion missing error states>
1243. **Medium** — <pyramid inversion that should be restructured>
125```
126
127## Coverage Classification Rules
128
129### Fully Covered
130All of the following must be true:
131- At least one test exists for the happy path
132- At least one test exists for an error or edge case
133- Tests are at the appropriate pyramid level (logic = unit, boundaries = integration, journeys = E2E)
134- Test assertions verify the correct behavior (not just "no error thrown")
135
136### Partially Covered
137Any of the following:
138- Happy path tested but no edge cases or error states
139- Tests exist but at the wrong pyramid level
140- Tests exist but assertions are weak (e.g., only checking status code, not response body)
141- Only one path through a conditional is tested
142
143### Uncovered
144- No test maps to this acceptance criterion at any level
145- A test exists with a similar name but does not actually verify the criterion's behavior
146
147## Content Guidelines
148
149### What Counts as an Acceptance Criterion
150- Explicit "Given/When/Then" statements in user stories
151- "The system shall..." requirements
152- Validation rules (e.g., "email must be valid format")
153- Business rules (e.g., "discount applies only to orders over $50")
154- Non-functional requirements (e.g., "page loads in under 2 seconds")
155- Error handling requirements (e.g., "invalid input shows error message")
156
157### What Does NOT Count as Coverage
158- A test file existing for a module (the tests must actually verify the criterion)
159- Code coverage percentage (100% line coverage can still miss acceptance criteria)
160- Tests that only exercise code without meaningful assertions
161- Tests that verify implementation details rather than behavior
162
163## Anti-patterns
164
165- **Counting tests instead of checking coverage** — 200 unit tests means nothing if 5 acceptance criteria have zero tests. Coverage is about requirements traceability, not test count.
166- **Ignoring edge case coverage** — A criterion marked "covered" because the happy path works, while boundary values, null inputs, and error states are untested. Partial coverage must be flagged honestly.
167- **Only checking unit test presence** — Integration boundaries and E2E user journeys need their own tests. A feature with 50 unit tests but no integration test for the API contract is not fully covered.
168- **Treating code coverage as test coverage** — Code coverage measures which lines were executed, not whether the behavior is correct. A test that calls a function without asserting the result gives you line coverage but zero behavioral coverage.
169- **Not reading the actual test assertions** — A test named `test_user_registration` might only check that no exception is thrown, not that the user is actually created with the correct data. Read the assertions, not just the test names.
170- **Marking derived criteria as uncovered without context** — If acceptance criteria were derived (not from a formal document), note that they are derived and flag for product confirmation rather than marking as a gap.