mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-21 22:00:07 -05:00
7534e8abe7
Describe how GET /api/openapi.json sets info.version via get_version_from_setup() (setup.py at runtime, with TIMETRACKER_VERSION or APP_VERSION overrides and Flask APP_VERSION fallback), and point contributors to the same rules in version management and project structure docs. Update the documentation audit entry for the former hardcoded OpenAPI version gap, document tests/test_api_route_contract.py and the refined test_api_v1 isolation guidance in the testing strategy, add a quick-reference pytest invocation for the contract suite, and note info.version in the API consistency audit next to the OpenAPI references.
1.9 KiB
1.9 KiB
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.