Framework Mode - Coverage in CI pipelines
Folder Structure
project-root/ ├── tests/ │ ├── test_example.py │ └── __init__.py ├── src/ │ └── app_code.py ├── .github/ │ └── workflows/ │ └── ci.yml ├── pytest.ini ├── requirements.txt └── README.md
Jump into concepts and practice - no test required
project-root/ ├── tests/ │ ├── test_example.py │ └── __init__.py ├── src/ │ └── app_code.py ├── .github/ │ └── workflows/ │ └── ci.yml ├── pytest.ini ├── requirements.txt └── README.md
tests/ folder, contains pytest test files like test_example.py.src/ folder.pytest.ini for pytest settings and coverage options..github/workflows/ci.yml to run tests and collect coverage.tests/ or separate utils/ folder if needed.[pytest] section with addopts = --cov=src --cov-report=xml to generate coverage XML report.ci.yml, install dependencies, run pytest with coverage, and upload coverage reports..coverage and reports in workspace for analysis.Where in this folder structure would you add a new pytest fixture to share setup code across tests?
pytest --cov in CI pipelines?--cov to specify coverage on the current directory.pytest --cov=myapp --cov-report=term
term option prints coverage summary in the terminal output.pytest --cov=myapp --cov-report=html
htmlcov in the current directory.--cov-fail-under which sets a minimum coverage percentage.