Run Tests
Execute the project's test suite, analyze failures, attempt fixes, and re-run. Designed as a reusable sub-workflow called by /feature-dev, /bugfix, and /pre-commit.
Uses testing-procedures skill for test writing patterns and coverage targets.
1. Detect Test Stack
Read TESTING.md (if exists) for test commands, infrastructure, and credentials. Fall back to CLAUDE.md and project config to determine:
| Signal |
Stack |
Runner |
package.json + vitest/jest |
TypeScript/JS |
npx vitest run / npx jest |
pom.xml / build.gradle |
Java |
mvn test -q / gradle test |
pyproject.toml / pytest.ini |
Python |
pytest -x -q |
go.mod |
Go |
go test ./... |
*.csproj |
.NET |
dotnet test |
2. Run Tests
Execute the test suite:
// turbo
<test-command>
Capture:
- Exit code: 0 = all pass, non-zero = failures
- Output: Test names, pass/fail counts, error messages, stack traces
3. Analyze Failures
If tests fail, for each failure:
- Read the failing test — understand what it asserts
- Read the error message and stack trace — identify the actual vs expected
- Classify the failure:
| Classification |
Action |
| Code bug — test is correct, implementation is wrong |
Fix the implementation (Step 4) |
| Test bug — test is wrong or outdated |
Fix the test (Step 4) |
| Environment issue — missing dependency, port conflict, DB down |
Report to user (Step 5) |
| Flaky test — passes on re-run without changes |
Flag for investigation |
4. Fix and Re-Run
For auto-fixable failures:
- Apply the appropriate stack-specific role (
Agent(frontend-engineer), Agent(java-engineer), Agent(python-engineer), etc.)
- Apply the minimal fix — do not refactor unrelated code
- Re-run the failing test(s) specifically:
| Stack |
Run Single Test |
| Vitest |
npx vitest run <test-file> |
| Jest |
npx jest <test-file> |
| pytest |
pytest <test-file>::<test-name> -v |
| JUnit/Maven |
mvn test -pl <module> -Dtest=<TestClass>#<method> |
| Go |
go test -run <TestName> ./path/... |
- If the fix works, re-run the full suite to check for regressions
- Max 3 fix attempts per failure — if still failing after 3 tries, escalate to user
5. Coverage Check (if available)
Run coverage report:
| Stack |
Command |
| Vitest |
npx vitest run --coverage |
| Jest |
npx jest --coverage |
| pytest |
pytest --cov=<package> --cov-report=term-missing |
| Go |
go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out |
| JUnit |
mvn jacoco:report |
Compare against testing-procedures skill targets:
- Line coverage ≥ 80% (hard minimum 60%)
- Branch coverage ≥ 75% (hard minimum 50%)
- New code coverage ≥ 90%
6. Summary
## Test Results
| Metric | Value |
|--------|-------|
| Total tests | X |
| Passed | X |
| Failed | X |
| Skipped | X |
| Duration | Xs |
| Coverage | X% (target: 80%) |
### Failures Fixed
- [test name] — [what was wrong] — [fix applied]
### Remaining Failures (needs attention)
- [test name] — [error] — [classification]
### Coverage Gaps
- [file/module] — [current%] — [uncovered lines]
**Overall**: ✅ PASS / ❌ FAIL — [action needed]
Integration
- Called by:
/feature-dev, /bugfix, /pre-commit
- Skills:
testing-procedures skill
- Roles:
Agent(qa-engineer) (test strategy), stack-specific role (implementation)
1---2name: run-tests-53description: Run tests workflow — execute test suite, analyze failures, auto-fix obvious issues, re-run. Sub-workflow for /feature-dev, /bugfix, /pre-commit. Uses the `testing-procedures` skill.4---5
6# Run Tests
7
8Execute the project's test suite, analyze failures, attempt fixes, and re-run. Designed as a reusable sub-workflow called by `/feature-dev`, `/bugfix`, and `/pre-commit`.
9
10Uses `testing-procedures` skill for test writing patterns and coverage targets.
11
12## 1. Detect Test Stack
13
14Read `TESTING.md` (if exists) for test commands, infrastructure, and credentials. Fall back to `CLAUDE.md` and project config to determine:
15
16| Signal | Stack | Runner |
17|---|---|---|
18| `package.json` + vitest/jest | TypeScript/JS | `npx vitest run` / `npx jest` |
19| `pom.xml` / `build.gradle` | Java | `mvn test -q` / `gradle test` |
20| `pyproject.toml` / `pytest.ini` | Python | `pytest -x -q` |
21| `go.mod` | Go | `go test ./...` |
22| `*.csproj` | .NET | `dotnet test` |
23
24## 2. Run Tests
25
26Execute the test suite:
27
28```
29// turbo
30<test-command>
31```
32
33Capture:
34- **Exit code**: 0 = all pass, non-zero = failures
35- **Output**: Test names, pass/fail counts, error messages, stack traces
36
37## 3. Analyze Failures
38
39If tests fail, for each failure:
40
411. **Read the failing test** — understand what it asserts
422. **Read the error message and stack trace** — identify the actual vs expected
433. **Classify the failure**:
44
45| Classification | Action |
46|---|---|
47| **Code bug** — test is correct, implementation is wrong | Fix the implementation (Step 4) |
48| **Test bug** — test is wrong or outdated | Fix the test (Step 4) |
49| **Environment issue** — missing dependency, port conflict, DB down | Report to user (Step 5) |
50| **Flaky test** — passes on re-run without changes | Flag for investigation |
51
52## 4. Fix and Re-Run
53
54For auto-fixable failures:
55
561. Apply the appropriate stack-specific role (`Agent(frontend-engineer)`, `Agent(java-engineer)`, `Agent(python-engineer)`, etc.)
572. Apply the minimal fix — do not refactor unrelated code
583. Re-run the failing test(s) specifically:
59
60| Stack | Run Single Test |
61|---|---|
62| Vitest | `npx vitest run <test-file>` |
63| Jest | `npx jest <test-file>` |
64| pytest | `pytest <test-file>::<test-name> -v` |
65| JUnit/Maven | `mvn test -pl <module> -Dtest=<TestClass>#<method>` |
66| Go | `go test -run <TestName> ./path/...` |
67
684. If the fix works, re-run the full suite to check for regressions
695. **Max 3 fix attempts per failure** — if still failing after 3 tries, escalate to user
70
71## 5. Coverage Check (if available)
72
73Run coverage report:
74
75| Stack | Command |
76|---|---|
77| Vitest | `npx vitest run --coverage` |
78| Jest | `npx jest --coverage` |
79| pytest | `pytest --cov=<package> --cov-report=term-missing` |
80| Go | `go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out` |
81| JUnit | `mvn jacoco:report` |
82
83Compare against `testing-procedures` skill targets:
84- Line coverage ≥ 80% (hard minimum 60%)
85- Branch coverage ≥ 75% (hard minimum 50%)
86- New code coverage ≥ 90%
87
88## 6. Summary
89
90```
91## Test Results
92
93| Metric | Value |
94|--------|-------|
95| Total tests | X |
96| Passed | X |
97| Failed | X |
98| Skipped | X |
99| Duration | Xs |
100| Coverage | X% (target: 80%) |
101
102### Failures Fixed
103- [test name] — [what was wrong] — [fix applied]
104
105### Remaining Failures (needs attention)
106- [test name] — [error] — [classification]
107
108### Coverage Gaps
109- [file/module] — [current%] — [uncovered lines]
110
111**Overall**: ✅ PASS / ❌ FAIL — [action needed]
112```
113
114## Integration
115
116- **Called by**: `/feature-dev`, `/bugfix`, `/pre-commit`
117- **Skills**: `testing-procedures` skill
118- **Roles**: `Agent(qa-engineer)` (test strategy), stack-specific role (implementation)