Development cycle testing gate (Gate 3) - ensures unit test coverage for all acceptance criteria using TDD methodology (RED-GREEN-REFACTOR). Focus: Unit tests only.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
name: dev-testing description: | Development cycle testing gate (Gate 3) - ensures unit test coverage for all acceptance criteria using TDD methodology (RED-GREEN-REFACTOR). Focus: Unit tests only.
trigger: |
skip_when: |
sequence: after: [dev-implementation, dev-devops, dev-sre] before: [dev-review]
related: complementary: [test-driven-development, qa-analyst]
verification: automated: - command: "go test ./... -covermode=atomic -coverprofile=coverage.out 2>&1 && go tool cover -func=coverage.out | grep -E 'total:|PASS|FAIL'" description: "Go tests pass with branch coverage (atomic mode)" success_pattern: "PASS.total:.[8-9][0-9]|100" failure_pattern: "FAIL|total:.[0-7][0-9]" - command: "npm test -- --coverage 2>&1 | grep -E 'Tests:|Coverage'" description: "TypeScript tests pass with coverage" success_pattern: "Tests:.passed|Coverage.[8-9][0-9]|100" failure_pattern: "failed|Coverage.[0-7][0-9]" manual: - "Every acceptance criterion has at least one test in traceability matrix" - "RED phase failure output was captured before GREEN phase" - "No skipped or pending tests for this task"
examples:
See CLAUDE.md for canonical testing requirements.
Ensure every acceptance criterion has at least one unit test proving it works. Follow TDD methodology: RED (failing test) -> GREEN (minimal implementation) -> REFACTOR (clean up).
Core principle: Untested acceptance criteria are unverified claims. Each criterion MUST map to at least one executable unit test.
Scope: This gate focuses on unit tests.
See shared-patterns/shared-pressure-resistance.md for universal pressure scenarios.
Gate 3-specific note: Coverage threshold (85%) is MANDATORY minimum, not aspirational target. Below threshold = FAIL.
See shared-patterns/shared-anti-rationalization.md for universal anti-rationalizations.
Gate 3-specific rationalizations:
| Excuse | Reality |
|---|---|
| "Manual testing validates all criteria" | Manual tests are not executable, not repeatable. Gate 3 requires unit tests. |
| "Integration tests are better verification" | Gate 3 scope is unit tests only. Integration tests are different scope. |
| "These mocks make it a unit test" | If you hit DB/API/filesystem, it's integration. Mock the interface. |
| "PROJECT_RULES.md says 70% is OK" | Ring minimum is 85%. PROJECT_RULES.md can raise, not lower. |
See shared-patterns/shared-red-flags.md for universal red flags (including Testing section).
If you catch yourself thinking ANY of those patterns, STOP immediately. Write unit tests until threshold met.
Ring establishes MINIMUM thresholds. PROJECT_RULES.md can only ADD constraints:
| Source | Can Raise? | Can Lower? |
|---|---|---|
| Ring Standard (85%) | N/A (baseline) | N/A (baseline) |
| PROJECT_RULES.md | ✅ YES (e.g., 90%) | ❌ NO |
| Team Decision | ✅ YES (e.g., 95%) | ❌ NO |
| Manager Override | ❌ NO | ❌ NO |
Coverage tool output is the SOURCE OF TRUTH. No adjustments allowed:
| Scenario | Allowed? | Required Action |
|---|---|---|
| Exclude dead code from measurement | ❌ NO | Delete the dead code |
Use // coverage:ignore annotations | ⚠️ ONLY with justification | Must document WHY in PR |
| "Mental math" adjustments | ❌ NO | Use actual tool output |
| Different tools show different % | Use lowest | Conservative approach |
Valid exclusion annotations (must be documented):
INVALID exclusion reasons:
If you believe the coverage tool is wrong:
| Step | Action | Why |
|---|---|---|
| 1 | Document the discrepancy | "Tool shows 83%, I expect 90%" |
| 2 | Investigate root cause | Missing test? Tool bug? Config issue? |
| 3 | Fix the issue | Add test OR fix tool config |
| 4 | Re-run coverage | Get new measurement |
| 5 | Use NEW measurement | No mental math on old number |
You CANNOT proceed with "the tool is wrong, real coverage is higher."
See shared-patterns/shared-anti-rationalization.md for universal anti-rationalizations.
| Rationalization | Why It's WRONG | Required Action |
|---|---|---|
| "Tool shows 83% but real is 90%" | Tool output IS real. Your belief is not. | Fix issue, re-measure |
| "Excluding dead code gets us to 85%" | Delete dead code, don't exclude it. | Delete dead code |
| "Test files lower the average" | Test files should be excluded by tool config. | Fix tool configuration |
| "Generated code tanks coverage" | Generated code should be excluded by pattern. | Add exclusion pattern |
| "84.5% rounds to 85%" | Rounding is not allowed. 84.5% < 85%. | Write more tests |
| "Close enough with all AC tested" | "Close enough" is not a passing grade. | Meet exact threshold |
If PROJECT_RULES.md specifies < 85%:
Gate 3 requires UNIT tests. Know the difference:
| Type | Characteristics | Gate 3? |
|---|---|---|
| Unit ✅ | Mocks all external dependencies, tests single function | YES |
| Integration ❌ | Hits real database/API/filesystem | NO - separate scope |
If you're thinking "but my test needs the database":
"Mocking the database driver" is still integration. Mock the INTERFACE.
Before starting this gate:
Create traceability matrix: | ID | Criterion | Test File | Test Function | Status (Pending/PASS) |
Rule: Every criterion MUST have at least one unit test. No criterion left untested.
| Criterion Type | Testable Unit | Mock Dependencies |
|---|---|---|
| Business logic | Service methods | Repository, external APIs |
| Validation | Validators, DTOs | None (pure functions) |
| Domain rules | Entity methods | None |
| Error handling | Service methods | Force error conditions |
| Phase | Action | Verify |
|---|---|---|
| RED | Write test describing expected behavior | Test runs + fails for right reason (feature missing, not typo) + paste failure output |
| GREEN | Write minimal code to pass | Test passes |
| REFACTOR | Remove duplication, improve naming, extract helpers | Tests still pass |
Dispatch: Task(subagent_type: "qa-analyst") with TASK_ID, ACCEPTANCE_CRITERIA, IMPLEMENTATION_FILES. Requirements: 1+ test/criterion, edge cases, mock deps, naming: Test{Unit}_{Method}_{Scenario}. Unit tests ONLY.
Run: go test ./... -covermode=atomic -coverprofile=coverage.out && go tool cover -func=coverage.out (or npm test -- --coverage, pytest --cov=src). Verify coverage ≥85%.
Update matrix with line numbers and PASS status for each criterion.
Before proceeding to Gate 4 (Review):
⛔ HARD GATE: ALL quality checks must PASS, not just coverage %
| Check | Verification | PASS Criteria |
|---|---|---|
| [ ] Skipped tests | grep -rn "\.skip|\.todo|xit|xdescribe" | 0 found |
| [ ] Assertion-less tests | Review test bodies for expect/assert | 0 found |
| [ ] Shared state | Check beforeAll/afterAll usage | No shared mutable state |
| [ ] Naming convention | Pattern: Test{Unit}_{Scenario} | 100% compliant |
| [ ] Edge cases | Count per AC | ≥2 edge cases per AC |
| [ ] TDD evidence | Captured RED phase output | All new tests |
| [ ] Test isolation | No execution order dependency | Tests pass in any order |
Why this matters: Issues caught here won't escape to dev-refactor. If dev-refactor finds test-related issues, Gate 3 failed.
| AC Type | Required Edge Cases | Minimum |
|---|---|---|
| Input validation | null, empty, boundary, invalid format | 3+ |
| CRUD operations | not found, duplicate, concurrent access | 3+ |
| Business logic | zero, negative, overflow, boundary | 3+ |
| Error handling | timeout, connection failure, retry exhausted | 2+ |
Rule: Happy path only = incomplete testing. Each AC needs edge cases.
QA Analyst returns VERDICT: PASS or VERDICT: FAIL.
PASS (coverage ≥ threshold) → Proceed to Gate 4 (Review)
FAIL (coverage < threshold) → Return to Gate 0 (Implementation)
The dev-cycle orchestrator tracks iteration count in state:
{
"testing": {
"iteration": 1,
"verdict": "FAIL",
"coverage_actual": 72.5,
"coverage_threshold": 85
}
}
Enforcement rules:
iteration on each Gate 3 entryIf tests fail during execution:
Never:
Always:
Base metrics per shared-patterns/output-execution-report.md.
| Metric | Value |
|---|---|
| Duration | Xm Ys |
| Iterations | N |
| Unit Tests Written | X |
| Coverage | XX.X% |
| Criteria Covered | X/Y (100%) |
| Result | PASS/FAIL |
| Issue | Recovery Steps |
|---|---|
| Tests without RED phase | Delete impl → Run test (must fail) → Restore impl (must pass) → If passes without impl: test is wrong, rewrite |
| Coverage below threshold | Identify uncovered lines → Write unit tests for gaps → Re-run coverage → Repeat until ≥85% |
| Criterion has no test | STOP → Write unit test → Full TDD cycle → Update matrix |