6 / 14 · Book 2 · The Anatomy of a Test-Generation Prompt← prev⊞ allnext →Get the book →
1.6Element 4: Coverage Goals
Without explicit coverage goals, the LLM defaults to happy-path tests. This is perhaps the most critical element to get right, because it directly determines whether your test suite catches bugs or merely occupies disk space.
Explicit coverage requirements:
**Coverage requirements:**
- Every acceptance criterion must have at least one test
- Include at least 2 negative/error cases per endpoint
- Include 1 boundary value test for every numeric field
- Test auth: valid token, expired token, missing token, wrong role
- Test idempotency: calling the endpoint twice with the same cart_id
- Test concurrent access: two users modifying the same resource
- Test pagination: first page, last page, empty page, page beyond total
Coverage categories to consider:
| Category | Examples | Why AI Misses It |
|---|---|---|
| Happy path | Valid input, successful response | AI covers this well |
| Validation errors | Missing fields, wrong types, out-of-range | AI covers partially |
| Auth failures | No token, expired token, wrong role | AI often omits role-based tests |
| Resource conflicts | Duplicate key, stock conflict, race condition | AI rarely considers |
| Boundary values | Min, max, min-1, max+1 for every numeric field | AI covers if prompted |
| State transitions | Valid and invalid state changes | AI almost never considers |
| Pagination | Edge cases around page boundaries | AI rarely generates |
| Idempotency | Repeat requests, duplicate submissions | AI almost never considers |
| Concurrency | Parallel modifications, optimistic locking | AI cannot generate well |
The negative-to-positive ratio
A good test suite has approximately a 2:1 ratio of negative (error) tests to positive (success) tests. This is because there are more ways for things to go wrong than right. If the AI generates 10 tests and 8 are happy-path, your prompt needs stronger coverage goals.
**Coverage ratio guidance:**
For each endpoint:
- 2-3 happy path tests (valid variations)
- 4-6 validation error tests (missing fields, wrong types, boundaries)
- 2-3 auth error tests (no token, wrong role, expired)
- 1-2 conflict/state tests (duplicate, out-of-stock)
- 1-2 edge case tests (empty arrays, maximum sizes, special characters)