| name | Test Execution |
| description | Strategies for running tests including inline, pytest, and Playwright |
Test Execution Skill
This skill provides test execution strategies for different project types.
When to Use
- QA verification of completed tasks
- Running unit/integration/e2e tests
- Debugging test failures
Strategy 1: Inline Test (Script/Library Projects)
Best for simple validation without import complexity.
write_file("project_tracking/test_inline.py", """
from dummy_math import add # No import issues - same directory!
result = add(2, 3)
expected = 5
if result == expected:
print(f"✅ PASS: add(2, 3) = {result}")
exit(0)
else:
print(f"❌ FAIL: add(2, 3) = {result}, expected {expected}")
exit(1)
""")
run_command("cd project_tracking && python test_inline.py")
Strategy 2: Pytest (Standard Projects)
pytest tests/test_feature.py -v
pytest -k "test_user" -v
pytest --cov=src tests/
Strategy 3: Playwright (Web UI Testing)
CRITICAL: Always use headless mode for autonomous execution.
export default defineConfig({
use: {
headless: true,
baseURL: 'http://localhost:5173',
},
});
npx playwright test
Circuit Breaker Pattern
Max 3 retries for same error:
- Attempt 1: pytest → ModuleNotFoundError
- Attempt 2: sys.path fix → ModuleNotFoundError
- Attempt 3: importlib → ModuleNotFoundError
- STOP → Switch to inline strategy
Failure Investigation
When test fails, categorize:
| Category | Action |
|---|
| Environment Issue | Mark BLOCKED, document |
| Test Code Issue | Fix test, re-run |
| Application Defect | Create DEFECT task |
Evidence Logging
Always include test output in completion:
VERIFIED:
- pytest tests/test_auth.py: 5 passed, 0 failed
- Coverage: 87%