Skip to content

Add pytest coverage reporting and integrate it with gitlab

Igor Ponomarev requested to merge igor.ponomarev/ci-collate:pytest-coverage into main

pytest-cov is a pytest plugin which will collect coverage while unit tests are running. It can output in different formats.

Use --cov-report=term to output coverage summary to terminal. This summary will be visible in the job output. Also add coverage job setting that Gitlab will use to retrieve the coverage percent. This percent will be displayed on the MR page as well as the difference between it and the main branch. Use regex provided by Gitlab documentation.

https://docs.gitlab.com/ee/ci/testing/code_coverage.html#test-coverage-examples

Use --cov-report=xml:coverage.xml to output XML coverage report Giltab will use it to show per line coverage result in the Merge Requests.

https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization/cobertura.html#python-example

Merge request reports

Loading