@endgame-build/claude-workflows
Version:
Claude Code workflow system with commands, agents, and templates for AI-native development
137 lines (107 loc) • 4.16 kB
Markdown
description: Create and execute comprehensive tests for implemented features
argument-hint: <instance-name> <feature name or description>
# /eg:test
You are tasked with creating and executing comprehensive tests for implemented features, including unit tests, integration tests, and end-to-end tests based on the feature definition and implementation.
Input: `$ARGUMENTS`
## Step 1: Parse Arguments and Gather Context
Parse the arguments to extract:
- Instance name (first word before space)
- Feature name or description (everything after first space)
Gather context:
- Read feature definition from `.eg/{instance-name}/feature-definition.md` if it exists
- Review implementation to understand what needs testing
- Identify testing framework from the project
## Step 2: Generate Comprehensive Tests
Use the Task tool to create tests:
```
Task(
description="Create comprehensive test suite",
prompt=`
Create comprehensive tests for: {feature-description}
Context:
- Feature definition: @.eg/{instance-name}/feature-definition.md (if exists)
- Implementation to test: Review recent code changes
Create tests including:
1. Unit tests for individual functions/methods
2. Integration tests for component interactions
3. End-to-end tests for user scenarios (use playwright-mcp if applicable)
4. Edge case tests based on boundary conditions
5. Error handling tests
6. Performance tests where relevant
Focus on:
- Acceptance criteria from feature definition
- Happy path scenarios
- Edge cases and boundary conditions
- Error conditions and exception handling
- Security-related test cases
- Performance and load considerations
Follow project testing conventions and framework.
Use descriptive test names that explain what is being tested.
Ensure tests are maintainable, fast, and provide clear failure messages.
`,
subagent_type="tester"
)
```
## Step 3: Execute Tests
Run the generated tests:
```
# Detect and run appropriate test command
!if [ -f "package.json" ]; then
npm test || yarn test || pnpm test
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
pytest || python -m pytest
elif [ -f "go.mod" ]; then
go test ./...
elif [ -f "Cargo.toml" ]; then
cargo test
else
echo "Could not detect test framework"
fi
```
## Step 4: Analyze Results
Capture and analyze test results:
- Number of tests created
- Pass/fail statistics
- Coverage percentage (if available)
- Any failures or issues
If tests fail:
- Analyze failure reasons
- Determine if it's a test issue or code issue
- Fix and re-run as needed
## Step 5: Report Summary
Document test results using the template:
```
Task(
description="Document test results",
prompt=`
Create a comprehensive test report for the executed tests.
Use the test results template from .claude/templates/test-results.template.md
Include:
- Test summary with pass/fail counts by type
- Coverage metrics (line, branch, function)
- Detailed results for each test category
- Failed test analysis with root causes
- Performance metrics
- Recommendations for improvement
Save the report to: .eg/{instance-name}/test-results.md
`,
subagent_type="summarizer"
)
```
- Recommendations for additional testing
## Step 6: Phase Gate and Completion
### Phase Gate - Test Results Review
Present test results and ask for approval:
- If all tests pass: "All tests passing with {coverage}% coverage. Feature ready for deployment? (yes/no)"
- If some tests fail: "Found {failed} failing tests. Should we: a) Fix the failures, b) Review if tests are correct, c) Accept known issues? (a/b/c)"
Based on response:
- If yes (all passing): "Feature testing complete! Ready for deployment or PR creation."
- If no: "What additional testing or coverage is needed?"
- If fixing failures: "Use `/eg:implement {instance-name}` to fix the failing tests"
- If reviewing tests: "Let's review the test assumptions and requirements"
Save test summary:
```
!echo "Test results saved to .eg/{instance-name}/test-results.md"
```