| description | tools |
|---|---|
Document all tests in this project. Keep the lists up-to-date. |
Bash, Glob, Grep, Read, Write, Edit |
Document tests efficiently using framework discovery and incremental updates. Handles multi-language projects.
First check if the project's claude.md (or CLAUDE.md) file contains testing framework information. If not, detect frameworks and update the file with:
- Testing frameworks used
- Commands to list all tests
- Test file patterns
- Check Project Documentation: Look for
claude.mdorCLAUDE.mdin project root - Verify Testing Info: Check if testing frameworks and commands are documented
- Detect if Missing: If absent, detect frameworks by directory
- Update claude.md: Add testing section with frameworks and commands
- Document Tests: Proceed with test documentation using detected frameworks
When reading the project's claude.md, look for a section about testing (headers like "Testing", "Tests", "Test Frameworks", etc.). Complete testing information should include:
- Framework names (e.g., Jest, xUnit, pytest)
- Test file patterns or locations
- Commands to list or run tests
If any of these are missing, the testing section is incomplete and should be updated.
If the project's claude.md (or CLAUDE.md) is missing testing information, add or update a section like:
## Testing
### Frameworks
- **Frontend**: Jest (JavaScript/TypeScript)
- Test pattern: `**/*.test.{js,jsx,ts,tsx}`
- List tests: `npm test -- --listTests`
- **Backend**: xUnit (.NET)
- Test pattern: `**/*Tests.csproj`
- List tests: `dotnet test --list-tests`
- **API**: pytest (Python)
- Test pattern: `**/test_*.py`, `**/*_test.py`
- List tests: `pytest --collect-only -q`
### Commands
- Run all tests: `npm run test:all` or framework-specific commands
- Run specific suite: See framework commands aboveAdjust the format based on detected frameworks and project structure.
-
.NET: Look for
*.csproj,*.sln→ Usedotnet test --list-tests- Test runners: xUnit, NUnit, MSTest (detect from package references)
- Test patterns:
**/*Tests.csproj,**/*.Test.csproj,**/Tests/**/*.cs
-
JavaScript/TypeScript: Look for
package.json→ Check for jest/vitest/mocha/jasmine- Jest:
npm test -- --listTestsornpx jest --listTests - Vitest:
npx vitest listor glob for test files - Mocha: Check scripts in package.json
- Test patterns:
**/*.test.*,**/*.spec.*,**/__tests__/**/*
- Jest:
-
Python: Look for
pyproject.toml,pytest.ini,setup.cfg→ Usepytest --collect-only- unittest:
python -m unittest discover - Test patterns:
**/test_*.py,**/*_test.py,**/tests/**/*.py
- unittest:
-
Go: Look for
go.mod→ Usego test -list .- Test patterns:
**/*_test.go
- Test patterns:
-
Rust: Look for
Cargo.toml→ Usecargo test -- --list- Test patterns:
**/tests/**/*.rs, files with#[test]or#[cfg(test)]
- Test patterns:
-
Ruby: Look for
Gemfile→ Check for rspec/minitest- RSpec:
bundle exec rspec --dry-run - Test patterns:
**/spec/**/*_spec.rb,**/test/**/*_test.rb
- RSpec:
-
Java: Look for
pom.xmlorbuild.gradle→ Check for JUnit/TestNG- Maven:
mvn test -DdryRun=true - Gradle:
gradle test --dry-run - Test patterns:
**/src/test/**/*Test.java
- Maven:
Store in .test-docs-cache.json at project root:
{
"lastRun": "2025-12-22T10:30:00Z",
"directories": {
"frontend/": {
"framework": "vitest",
"testPattern": "**/*.test.ts"
},
"backend/": {
"framework": "dotnet",
"testRunner": "xunit"
},
"api/": {
"framework": "dotnet",
"testRunner": "nunit"
}
},
"files": {
"frontend/src/App.test.tsx": {
"mtime": 1703251200,
"hash": "abc123",
"directory": "frontend/"
},
"backend/Tests/UnitTest1.cs": {
"mtime": 1703251200,
"hash": "def456",
"directory": "backend/"
}
}
}Directory Detection Logic:
- Each test file belongs to a directory (find nearest parent with framework markers)
- Cache stores framework per directory
- On subsequent runs, use cached framework info for that directory
- Check for claude.md - Look for
claude.mdorCLAUDE.mdin project root - Parse existing testing info - Check if Testing section exists with frameworks and commands
- If testing info is missing or incomplete:
- Detect frameworks using the detection logic below
- Generate testing section with frameworks, patterns, and commands
- Update or create claude.md with the testing section
- Load cache - Read
.test-docs-cache.json(if documenting tests) - Find test files - Use git or glob to find test files
- Group by directory - Organize files by their parent directory
- For each directory:
- Use framework info from claude.md if available
- Otherwise, use cached framework or detect it
- Store detection result in cache
- Filter to changed files only - Compare mtimes from cache
- Process changed files using appropriate framework commands
- Update docs/tests.md - Merge with existing content
- Save cache with updated directory frameworks and file metadata
- List tests:
dotnet test --list-tests --no-buildordotnet test -t - Find test projects: Glob for
**/*Tests.csproj,**/*.Test.csproj - Detect runner: Parse .csproj for PackageReference (xunit, nunit, mstest)
- Common attributes:
[Fact],[Theory],[Test],[TestMethod]
- Jest:
jest --listTestsornpm test -- --listTests - Vitest:
vitest listor glob for test files - Common patterns:
**/*.test.*,**/*.spec.*,**/__tests__/**/*
CRITICAL: All tests MUST be documented in tables. NEVER use bullet lists for test documentation.
Add or append to docs/tests.md in markdown format. Each test type section MUST contain a table.
Required table columns for ALL test groups:
- File Path
- Test Name (class/function + method)
- Description (what is being tested)
Group tests by type using section headers, with each section containing a table:
| File Path | Test Name | Description |
|---|---|---|
| ... | ... | ... |
| File Path | Test Name | Description |
|---|---|---|
| ... | ... | ... |
Available test type sections (only include those that exist in the project):
- Unit Tests - Isolated tests for individual functions/classes
- Integration Tests - Tests for component interactions
- E2E Tests - End-to-end user flow tests
- Snapshot Tests - UI/output snapshot comparisons
- Contract Tests - API contract verification
- Performance Tests - Load/stress/benchmark tests
IMPORTANT: Every test group MUST use the table format shown above. Do NOT create bullet lists.