Ensure your codebase is robust, reliable, and maintainable by following these core testing practices.
- Framework: Use PHPUnit for all tests.
- What to Test:
- Public Interfaces:
- For libraries: public methods
- For API backends: API endpoints
- For modular monoliths: Module Interfaces
- Public Interfaces:
- Coverage:
- No hard minimums, but strive for meaningful coverage to catch regressions and remove dead code.
- Feature Tests:
- Required for all API endpoints and Module API Interface methods.
- Middleware:
- If middleware is disabled or bypassed in feature tests, ensure you write dedicated unit tests for it.
- Use the
#[Test]attribute for all test methods. - Naming:
- Use snake_case for test method names to maximize readability.