You are automating the build process for a Java-based application by using Azure DevOps.
You need to add code coverage testing and publish the outcomes to the pipeline.
What should you use?
Click on the arrows to vote for the correct answer
A. B. C. D.C
Use Publish Code Coverage Results task in a build pipeline to publish code coverage results to Azure Pipelines or TFS, which were produced by a build in
Cobertura or JaCoCo format.
Incorrect Answers:
A: Bullseye Coverage is used for C++ code, and not for Java.
Note:
There are several versions of this question in the exam. The question has two possible correct answers:
-> Cobertura
-> JaCoCo
Other incorrect answer options you may see on the exam include the following:
-> Coverlet
-> NUnit
-> Coverage.py
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-resultsTo add code coverage testing and publish the outcomes to the pipeline, you can use JaCoCo.
JaCoCo (Java Code Coverage) is an open-source code coverage library for Java-based applications. It provides accurate and detailed coverage reports for Java code, including line coverage, branch coverage, and method coverage.
To use JaCoCo in Azure DevOps, you can add the JaCoCo plugin to your build pipeline. Here are the steps:
php<build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.4</version> <executions> <execution> <id>prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>report</id> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
In your Azure DevOps pipeline, add a Maven task to build your Java project:
Add a JaCoCo report task to your pipeline:
Run the pipeline and view the JaCoCo coverage report:
In conclusion, JaCoCo is the appropriate tool to use for adding code coverage testing and publishing the outcomes to the pipeline in Azure DevOps.