If you're getting:
FAIL Required test coverage of 50% not reached. Total coverage: 27.81%
The Fix:
# Don't run coverage on route tests alone
pytest -m routes -v
# Instead, run coverage on ALL tests
pytest --cov=app --cov-report=html --cov-fail-under=50Or use the Makefile:
# Run route tests (no coverage)
make test-routes
# Run full coverage test
make test-coverageRoute tests only exercise ~28% of your codebase (which is correct!). The other 72% is tested by:
- Model tests
- Utility tests
- Integration tests
- Business logic tests
Coverage should be measured across ALL tests, not individual test suites.
make test-routes # Test routes only
make test-models # Test models only
make test-unit # Test unit tests only
make test-integration # Test integration only
make test-api # Test API endpoints
pytest tests/test_api_route_contract.py -v # Curated URL map + OpenAPI version vs setup.pymake test-coverage # All tests with 50% requirement
make test-coverage-report # All tests, no requirementmake test-smoke # Quick validation (< 1 min)
pytest --cov=app --cov-report=xml --cov-fail-under=50 # Full CI testmake test-coverage-report
# Then open htmlcov/index.html in your browserRun specific test types:
pytest -m smoke # Smoke tests
pytest -m unit # Unit tests
pytest -m integration # Integration tests
pytest -m routes # Route tests
pytest -m api # API tests
pytest -m models # Model tests
pytest -m database # Database tests
pytest -m security # Security testsSee docs/TESTING_COVERAGE_GUIDE.md for complete guide.