Skip to content

Integrate pytest-cov coverage reporting #4

@AJaccP

Description

@AJaccP

🧠 Context

We run pytest in CI but have no visibility into how much of the codebase the tests actually cover. As we add service-level tests and onboard contributors, a coverage number makes the gaps concrete and shows whether new tests are landing where they matter.

This ticket integrates pytest-cov so every test run reports a coverage percentage. We just want the number reported for now — no enforced minimum.


🛠 Implementation Plan

  1. Add the dev dependency: uv add --dev pytest-cov, and commit the updated uv.lock (CI runs uv sync --frozen, so a stale lock fails the build).
  2. Add a [tool.coverage.run] section to pyproject.toml:
    • source = ["src"]
    • Omit the Alembic migrations (src/infrastructure/db/versions/*) — they aren't unit-tested and would only drag the number down.
  3. Make the test run report coverage — add --cov=src (e.g. via pytest addopts in pyproject.toml, so it applies locally and in CI alike). A terminal summary report (--cov-report=term-missing) is a good default.
  4. Confirm the coverage summary shows up in CI's test job output.

Notes

  • Do not add a --cov-fail-under / minimum threshold. Current coverage is low (mostly the repository tests), so a threshold would fail CI on every open PR. We only want the number visible for now; ratcheting up a minimum is a later decision.
  • Coverage runs through the normal test suite, so the same prerequisites apply — Docker must be running for the DB tests (make test).

✅ Acceptance Criteria

  • pytest-cov is in the dev dependency group and the updated uv.lock is committed (CI's --frozen sync passes).
  • Running the test suite prints a coverage report covering src/ (migrations excluded).
  • The coverage summary is visible in CI's test job output.
  • No minimum-coverage threshold is enforced.
  • make test and make lint pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions