| description | Smart test runner with filtering, coverage, and health monitoring |
|---|---|
| argument-hint | Test target and optional flags (backend, frontend, --coverage, --watch) |
You are helping a developer run tests with smart filtering, comprehensive reporting, and test suite health monitoring. Parse arguments to determine test scope, execute appropriate test commands, analyze results, and provide actionable recommendations.
/test # Run all tests
/test backend # Run backend tests only
/test frontend --watch # Run frontend tests in watch mode
/test integration --verbose # Run integration tests with verbose output
/test --coverage # Run with coverage reportExtract test target and flags from arguments:
Test Targets (first positional argument):
backend- Run backend/server testsfrontend- Run frontend/client testsintegration- Run integration tests onlyunit- Run unit tests onlye2e- Run end-to-end tests[specific-file]- Run specific test file- No argument - Run all tests
Flags (optional parameters):
--watch- Watch mode (re-run on file changes)--coverage- Generate coverage report--verbose- Detailed output with logs--bail- Stop on first failure--update-snapshots- Update test snapshots
Map arguments to appropriate test commands:
# Examples
backend → pytest tests/backend/ -v
frontend → npm test -- --testPathPattern=frontend
integration → pytest tests/integration/ -v
backend --coverage → pytest tests/backend/ --cov=src/backend --cov-report=html
frontend --watch → npm test -- --watch --testPathPattern=frontendRun the determined test command:
# Set up test environment
export NODE_ENV=test
export TESTING=true
# Run tests with appropriate flags
[test_command]Extract key metrics from test output:
- Total tests run
- Tests passed/failed/skipped
- Test duration
- Coverage percentage (if --coverage flag used)
- Failed test details (if any)
Create structured test report:
## Test Report
**Target**: [backend/frontend/integration/all]
**Date**: 2025-01-10 14:45:12
**Duration**: 8.2 seconds
### Results
- ✅ Passed: 245
- ❌ Failed: 2
- ⏭️ Skipped: 5
- **Total**: 252 tests
### Coverage (if applicable)
- Statements: 85%
- Branches: 78%
- Functions: 90%
- Lines: 84%
### Failed Tests
1. **test_user_authentication_with_expired_token**
- Location: tests/backend/test_auth.py:42
- Error: AssertionError: Expected 401, got 200
- Duration: 0.05s
2. **test_checkout_with_invalid_payment**
- Location: tests/backend/test_checkout.py:78
- Error: Timeout after 5000ms
- Duration: 5.2s
### Recommendations
- Fix failed authentication test (expired token not being rejected)
- Investigate checkout test timeout (possible mock issue)
- Consider increasing coverage for src/payment.js (currently 65%)If no arguments provided, intelligently determine what to test:
Check Recent Changes:
# Find recently modified files
git diff --name-only HEAD~1 HEADRun Affected Tests:
- If backend files changed → Run backend tests
- If frontend files changed → Run frontend tests
- If both changed → Run integration tests
- If config/infrastructure changed → Run all tests
Track test suite health over time:
### Test Suite Health
- Test suite duration trend: ⬆️ +12% (last 7 days)
- Suggestion: Investigate slow tests, consider parallelization
- Flaky tests detected: 3
- test_api_timeout (flaky rate: 15%)
- test_websocket_connection (flaky rate: 8%)
- test_cache_expiration (flaky rate: 5%)
- Coverage trend: 📈 85% → 87% (+2%)For large test suites, run tests in parallel:
# Pytest parallel
pytest -n auto tests/
# Jest parallel (default)
npm test -- --maxWorkers=4Run critical tests first:
- Recently failed tests
- Tests covering recently changed code
- High-value integration tests
- Remaining unit tests
In watch mode, only re-run tests related to changed files:
# Watch backend changes
npm test -- --watch --testPathPattern=backend
# Automatically run related tests when files changeNode.js / Jest:
npm test -- --testPathPattern=$ARGUMENTS
npm test -- --watch
npm test -- --coverage --coverageThreshold='{"global":{"branches":80,"functions":80,"lines":80}}'Python / Pytest:
pytest tests/$ARGUMENTS -v
pytest tests/$ARGUMENTS --cov=src --cov-report=html
pytest tests/$ARGUMENTS -x # Stop on first failureGo:
go test ./... -v
go test ./... -cover
go test -run $ARGUMENTSRuby / RSpec:
rspec spec/$ARGUMENTS
rspec spec/$ARGUMENTS --format documentationParse $ARGUMENTS to extract test target and flags:
- First positional argument: Test target (backend, frontend, integration, etc.)
- Remaining arguments: Flags (--watch, --coverage, --verbose, --bail)
- If no arguments: Use smart test selection based on recent git changes
- Always provide test summary with pass/fail counts
- Show failed test details with file locations
- Suggest fixes for common test failures
- Track test suite health metrics
- Recommend coverage improvements for low-coverage files
- Detect and report flaky tests
- Provide clear next steps based on results
- Use smart test selection when no target specified