Skip to content

pytest: improve branch coverage AND fix the tests #2501

@adamjstewart

Description

@adamjstewart

By default, coverage only reports which lines were executed during unit testing. By enabling branch coverage, we can also see whether if-statements are tested for both True and False conditions.

To enable this, simply add the following to pyproject.toml:

[tool.coverage.run]
branch = true

https://app.codecov.io/gh/microsoft/torchgeo/pull/2276/indirect-changes gives an idea of places where this coverage is missing. The real work involves adding new tests to add the missing coverage.

Reference: https://coverage.readthedocs.io/en/latest/branch.html

@isaaccorley edit -- We've had several PRs simply changing the above line is pyproject.toml, however the end goal of this issue is to not only change this line but also fix the missing branch tests so we obtain 100% code coverage. Please consider this effort when contributing a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueA good issue for a new contributor to work ontestingContinuous integration testing

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions