# Testing Requirements ## Coverage Threshold - **Minimum: 80% line coverage** for all backend code - Critical paths (auth, banning, scheduling, API endpoints): **100%** ## CI Enforcement `.github/workflows/ci.yml` runs pytest with `--cov-fail-under=80`. Build fails if coverage drops below threshold. ## Running Tests Locally ```bash cd backend pytest --cov=app --cov-report=term-missing ``` ## Coverage Reports - Terminal: `--cov-report=term-missing` - HTML: `--cov-report=html` (output in `htmlcov/`) ## Coverage Badge Add to README once CI runs successfully: ```md [![Coverage](https://codecov.io/gh//BanGUI/branch/main/graph/badge.svg)](https://codecov.io/gh//BanGUI) ``` Requires codecov.io integration with repository. ## Writing Tests - Follow pattern: `test___` - Mock external dependencies (fail2ban socket, aiohttp calls) - Test happy path AND error/edge cases - See `Docs/Backend-Development.md ยง9` for detailed testing guide