testing-workflow
Run and manage functional tests (unit, integration, E2E, mutation). Use when running tests, debugging test failures, ensuring test coverage, or fixing mutation testing issues. Covers PHPUnit, Behat, and Infection. For K6 load/performance tests, use the load-testing skill instead.
安装与使用
请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。
查看来源 ↗使用指南技能说明
Testing Workflow Skill
Context (Input)
- Code changes require test validation
- Test failures need debugging
- Coverage/mutation targets must be met
Task (Function)
Execute appropriate test suite and ensure 100% pass rate with required coverage.
Note: For K6 load/performance testing, see load-testing skill.
Test Commands Quick Reference
| Test Type | Command | Runtime | Coverage | Location |
|---|---|---|---|---|
| Unit | make unit-tests |
2-3 min | 100% | tests/Unit/ |
| Integration | make integration-tests |
3-5 min | Full | tests/Integration/ |
| E2E (Behat) | make behat |
5-10 min | BDD | features/ |
| All Tests | make all-tests |
8-15 min | 100% | All |
| Mutation | make infection |
Variable | 100% MSI | Unit tests |
Load Testing: Use load-testing skill for K6 performance tests.
Execution Workflow
Step 1: Run Tests
make unit-tests # For quick validation
make all-tests # For comprehensive check
Step 2: Check Results
- ✅ All Pass + 100% coverage → Complete
- ❌ Failures detected → Go to Step 3
Step 3: Debug Failures
Identify failure type and apply fix:
| Failure Type | Debug Command | Common Fixes |
|---|---|---|
| Assertion failure | PHPUnit output | Fix logic, update test expectations |
| Coverage < 100% | Coverage report | Add missing test cases |
| Escaped mutants | make infection output |
Test edge cases, strengthen assertions |
| Behat scenario | Feature output | Fix application logic or step definitions |
| Type error | Stack trace | Fix type hints, mock returns |
Step 4: Fix and Re-test
# Fix the code/tests
make unit-tests # Re-run to verify fix
Repeat Steps 2-4 until all tests pass with 100% coverage.
Mutation Testing (Infection)
Goal: 100% Mutation Score Indicator (MSI) - Zero escaped mutants
Run Mutation Tests
make infection
Fix Escaped Mutants
- Review mutation diff in output
- Add test case for uncaught mutation
- Strengthen assertion specificity
- Consider refactoring for testability
Example: If mutant changes > to >=, add boundary test case.
Faker Usage in Tests
Setup: Tests extend UnitTestCase which provides $this->faker
// Good - Dynamic test data
$this->faker->email();
$this->faker->lexify('??'); // 2 random letters
$this->faker->unique()->ulid();
// Bad - Hardcoded values
'test@example.com'
'AB'
Available:
-
$this->faker->ulid()- Domain ULID via custom provider - All standard Faker methods (email, name, word, etc.)
Load Testing
Commands:
make smoke-load-tests # Minimal load, 5-10 min
make average-load-tests # Normal traffic, 15-25 min
make stress-load-tests # High load, 20-30 min
make spike-load-tests # Extreme spikes, 25-35 min
Prerequisites:
- Test database seeded (
make setup-test-db) - Docker containers running (
make start) - K6 Docker image built
Constraints (Parameters)
NEVER:
- Cancel long-running tests mid-execution
- Commit with failing tests
- Accept coverage < 100%
- Allow escaped mutants
- Run tests outside Docker (use
makecommands)
ALWAYS:
- Use Faker for dynamic test data
- Mock external dependencies in unit tests
- Use real DB in integration tests
- Ensure deterministic test results
Format (Output)
Unit Tests Success:
OK (X tests, Y assertions)
✅ COVERAGE SUCCESS: Line coverage is 100%
Mutation Testing Success:
100% MSI
0 escaped mutants
Verification Checklist
- All tests pass
- Coverage is 100%
- Zero escaped mutants (if running mutation tests)
- No hardcoded test values (use Faker)
- Tests run in Docker container via
make
使用示例
查看来源仓库中的使用示例与配置说明。
查看来源 ↗来源历史
- 收录时间
- 2026-01-20
- 索引更新时间
- 2026-01-26
- Branch
- main
收录与同步日期属于本站记录。源码修改历史请查看来源仓库。
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!