Test-jdk11 : stage : test image : gradle:6.6.1-jdk11 script : - ' gradle test jacocoTestReport' # jacoco must be configured to create an xml report artifacts : paths : - build/jacoco/jacoco.xml coverage-jdk11 : # Must be in a stage later than test-jdk11's stage. The coverage-jdk-11 job converts the artifact into a Cobertura report: The test-jdk11 job tests the code and generates an GitLab expects the artifact in the Cobertura format, so you have to execute a few You can check the Docker image configuration and scripts if you want to build your own image. To build the project and JaCoCo coverage-tooling to gitlab-ci.yml example for Java or Kotlin uses Gradle stage : visualize image : /haynes/jacoco2cobertura:1.0.7 script : # convert report from jacoco to cobertura, using relative project path - python /opt/cover2cover.py target/site/jacoco/jacoco.xml $CI_PROJECT_DIR/src/main/java/ > target/site/cobertura.xml needs : artifacts : reports : coverage_report : coverage_format : cobertura path : target/site/cobertura.xml Gradle example # Please define it first, or choose an existing stage like `deploy`. # The `visualize` stage does not exist by default. Test-jdk11 : stage : test image : maven:3.6.3-jdk-11 script : - mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test jacoco:report artifacts : paths : - target/site/jacoco/jacoco.xml coverage-jdk11 : # Must be in a stage later than test-jdk11's stage. To draw the visualization on the merge request expires one week after creation. The visualization cannot be displayed if the blocking manual job did not run. Pipeline waits for the manual job before continuing and is not considered complete. The visualization only displays after the pipeline is complete. When submitting many files, it can take a few minutes for coverage to show on a merge request. For large projects, split the Cobertura XML into If your Cobertura report exceedsġ00 nodes, there can be mismatches or no matches in the merge request diff view.Ī single Cobertura XML file can be no more than 10 MiB. LimitsĪ limit of 100 nodes for Cobertura format XML files applies. Test coverage results in merge requests.Uploading a test coverage report does not enable: Hovering over the coverage bar provides further information, such as the number no coverage information: lines which are non-instrumented or not loaded.no test coverage (orange): lines which are loaded but never executed.covered (green): lines which have been checked at least once by tests.This includes reportsįrom any job in any stage in the pipeline. Once configured, if you create a merge request that triggers a pipeline which collectsĬoverage reports, the coverage is shown in the diff view. Other coverage analysis frameworks support the format out of the box, for example: This format was originally developed for Java, but most coverage analysis frameworksįor other languages have plugins to add support for it, like: Coverage files are parsed in a background job so there can be a delayīetween pipeline completion and the visualization loading on the page.įor the coverage analysis to work, you have to provide a properly formatted GitLab then takes the coverage information in all the files and combines it You can specify one or more coverage reports to collect, including wildcard paths. To see which lines are covered by tests, and which lines still require coverage, before theĬollecting the coverage information is done via GitLab CI/CD’s This information inside the file diff view of your merge requests (MRs). With the help of GitLab CI/CD, you can collect the testĬoverage information of your favorite testing or coverage-analysis tool, and visualize
0 Comments
Leave a Reply. |