summaryrefslogtreecommitdiff
path: root/doc/ci/testing/test_coverage_visualization.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ci/testing/test_coverage_visualization.md')
-rw-r--r--doc/ci/testing/test_coverage_visualization.md58
1 files changed, 33 insertions, 25 deletions
diff --git a/doc/ci/testing/test_coverage_visualization.md b/doc/ci/testing/test_coverage_visualization.md
index e2a1a4a2c5e..31d1b7f3337 100644
--- a/doc/ci/testing/test_coverage_visualization.md
+++ b/doc/ci/testing/test_coverage_visualization.md
@@ -1,6 +1,6 @@
---
stage: Verify
-group: Pipeline Insights
+group: Pipeline Execution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
---
@@ -33,7 +33,7 @@ This format was originally developed for Java, but most coverage analysis framew
for other languages have plugins to add support for it, like:
- [simplecov-cobertura](https://rubygems.org/gems/simplecov-cobertura) (Ruby)
-- [gocover-cobertura](https://github.com/boumenot/gocover-cobertura) (Golang)
+- [gocover-cobertura](https://github.com/boumenot/gocover-cobertura) (Go)
Other coverage analysis frameworks support the format out of the box, for example:
@@ -54,8 +54,8 @@ of times the line was checked by tests.
Uploading a test coverage report does not enable:
-- [Test coverage results in merge requests](../pipelines/settings.md#merge-request-test-coverage-results).
-- [Code coverage history](../pipelines/settings.md#view-code-coverage-history).
+- [Test coverage results in merge requests](code_coverage.md#view-code-coverage-results-in-the-mr).
+- [Code coverage history](code_coverage.md#view-history-of-project-code-coverage).
You must configure these separately.
@@ -112,24 +112,14 @@ attempts to build the full path by:
#### Path correction example
-As an example, a project with:
+As an example, a C# project with:
-- A full path of `test-org/test-project`.
+- A full path of `test-org/test-cs-project`.
- The following files relative to the project root:
```shell
Auth/User.cs
Lib/Utils/User.cs
- src/main/java
- ```
-
-In the:
-
-- Cobertura XML, the `filename` attribute in the `class` element assumes the value is a relative
- path to the project's root:
-
- ```xml
- <class name="packet.name" filename="src/main/java" line-rate="0.0" branch-rate="0.0" complexity="5">
```
- `sources` from Cobertura XML, the following paths in the format
@@ -137,8 +127,8 @@ In the:
```xml
<sources>
- <source>/builds/test-org/test-project/Auth</source>
- <source>/builds/test-org/test-project/Lib/Utils</source>
+ <source>/builds/test-org/test-cs-project/Auth</source>
+ <source>/builds/test-org/test-cs-project/Lib/Utils</source>
</sources>
```
@@ -153,6 +143,29 @@ The parser:
100 iterations. If it reaches this limit without finding a matching path in the file tree, the
class is not included in the final coverage report.
+Automatic class path correction also works for a Java project with:
+
+- A full path of `test-org/test-java-project`.
+- The following files relative to the project root:
+
+ ```shell
+ src/main/java/com/gitlab/security_products/tests/App.java
+ ```
+
+- `sources` from Cobertura XML:
+
+ ```xml
+ <sources>
+ <source>/builds/test-org/test-java-project/src/main/java/</source>
+ </sources>
+ ```
+
+- `class` element with the `filename` value of `com/gitlab/security_products/tests/App.java`:
+
+ ```xml
+ <class name="com.gitlab.security_products.tests.App" filename="com/gitlab/security_products/tests/App.java" line-rate="0.0" branch-rate="0.0" complexity="6.0">
+ ```
+
NOTE:
Automatic class path correction only works on `source` paths in the format `<CI_BUILDS_DIR>/<PROJECT_FULL_PATH>/...`.
The `source` is ignored if the path does not follow this pattern. The parser assumes that the
@@ -261,10 +274,7 @@ coverage-jdk11:
### Python example
-The following [`.gitlab-ci.yml`](../yaml/index.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`:
+The following [`.gitlab-ci.yml`](../yaml/index.md) example uses [pytest-cov](https://pytest-cov.readthedocs.io/) to collect test coverage data:
```yaml
run tests:
@@ -272,9 +282,7 @@ run tests:
image: python:3
script:
- pip install pytest pytest-cov
- - coverage run -m pytest
- - coverage report
- - coverage xml
+ - pytest --cov --cov-report term --cov-report xml:coverage.xml
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports: