Skip to content

Analyze test coverage with Pytest-cov and enforce coverage checks for new code #14

@uxabix

Description

@uxabix

We need to analyze the test coverage of the existing codebase with Pytest-cov and set up a process to verify test coverage for all new code changes.


Requirements

Coverage Analysis

  • Integrate pytest-cov into the test suite (update requirements.txt and pytest.ini as necessary).
  • Run coverage analysis on the current codebase to identify untested code sections.
  • Document current coverage metrics and highlight major gaps.

CI Integration

  • Update CI pipelines (e.g., GitHub Actions, GitLab CI) to include coverage checks on every PR and commit.
  • Optionally enforce or notify on minimum coverage thresholds (e.g., fail if coverage drops).
  • Provide clear coverage feedback in PRs for reviewers.

Best Practices

  • Encourage incremental addition of missing tests for uncovered areas.
  • Ensure tests for newly added code always provide adequate coverage.
  • Exclude configuration/migration files from coverage where applicable.

Recommendations

  • Minimum coverage: Start with a "report only" mode, then incrementally raise the enforcement threshold.
  • Coverage reporting: Prefer both HTML and terminal reports for maximum developer convenience.

Testing

  • Confirm that running tests locally (pytest --cov) produces an accurate coverage report.
  • Verify CI coverage check runs on PRs and reports results.
  • Test that coverage enforcement works by introducing uncovered code in a PR.

Definition of Done

  • Pytest-cov integrated and functionally reporting coverage.
  • All new code is covered by tests.
  • Coverage status documented in CI and developer workflow.
  • Gaps documented and plan created for addressing uncovered code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions