Commit a34e607a authored by Marcel Amirault's avatar Marcel Amirault

Merge branch 'docs/test_cov_viz-python_example' into 'master'

Docs: Add an Python example for test coverage visualization

See merge request gitlab-org/gitlab!48486
parents b5e7f9a2 be6e4c87
......@@ -154,3 +154,23 @@ coverage-jdk11:
reports:
cobertura: build/cobertura.xml
```
### Python example
The following [`gitlab-ci.yml`](../../../ci/yaml/README.md) example for Python uses [pytest-cov](https://pytest-cov.readthedocs.io/) to collect test coverage data and [coverage.py](https://coverage.readthedocs.io/) to convert the report to use full relative paths.
The information isn't displayed without the conversion.
This example assumes that the code for your package is in `src/` and your tests are in `tests.py`:
```yaml
run tests:
stage: test
image: python:3
script:
- pip install pytest pytest-cov
- pytest --cov=src/ tests.py
- coverage xml
artifacts:
reports:
cobertura: coverage.xml
```
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment