Code Coverage Testing and Publishing Outcomes in Azure DevOps | AZ-400 Exam Solution

Code Coverage Testing and Publishing Outcomes in Azure DevOps

Question

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?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A

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:

B: Bullseye Coverage is used for C++ code, and not for Java.

D: If you're building on Linux or macOS, you can use Coverlet or a similar tool to collect code coverage metrics. Code coverage results can be published to the server by using the Publish Code Coverage Results task. To leverage this functionality, the coverage tool must be configured to generate results in Cobertura or

JaCoCo coverage format.

F: Coverage.py is used for Python, not for Java.

Note:

There are several versions of this question in the exam. The question has two possible correct answers:

1. Cobertura

2. JaCoCo

Other incorrect answer options you may see on the exam include the following:

1. Junit

2. NUnit

3. Coverage.py

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/test/publish-code-coverage-results

To add code coverage testing to a Java-based application in Azure DevOps, the best tool to use would be Cobertura.

Cobertura is an open-source Java tool that can be used to calculate code coverage metrics for code that is executed during automated tests. It can be easily integrated into an Azure DevOps pipeline using a task like "Code Coverage and Analysis". Cobertura supports a wide range of coverage report formats, including HTML, XML, and JSON, making it easy to publish the coverage results to the pipeline.

Bullseye Coverage is a code coverage tool that is primarily designed for C++ and C# applications, so it would not be the best choice for a Java-based application.

MSTest is a testing framework that is primarily used for .NET applications, so it would not be suitable for a Java-based application.

Coverlet is a code coverage tool that is specifically designed for .NET Core applications, so it would not be the best choice for a Java-based application.

Therefore, option A, Cobertura, is the best choice for adding code coverage testing and publishing the outcomes to an Azure DevOps pipeline for a Java-based application.