Skip to content

Latest commit

 

History

History
84 lines (66 loc) · 1.93 KB

TESTING_QUICK_REFERENCE.md

File metadata and controls

84 lines (66 loc) · 1.93 KB

Testing Quick Reference

TL;DR - Fix for Coverage Error

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=50

Or use the Makefile:

# Run route tests (no coverage)
make test-routes

# Run full coverage test
make test-coverage

Why?

Route 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.

Common Commands

Development Testing

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.py

Coverage Analysis

make test-coverage        # All tests with 50% requirement
make test-coverage-report # All tests, no requirement

CI/CD Testing

make test-smoke          # Quick validation (< 1 min)
pytest --cov=app --cov-report=xml --cov-fail-under=50  # Full CI test

View Coverage Report

make test-coverage-report
# Then open htmlcov/index.html in your browser

Test Markers

Run 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 tests

Full Documentation

See docs/TESTING_COVERAGE_GUIDE.md for complete guide.