AZ-400 exam dumps

AZ-400 practice question 123 of 306

Designing and Implementing Microsoft DevOps Solutions. Professional level, Microsoft. Free question with the correct answer and a full explanation.

AZ-400 Question 123

Single answer

Your team is building a .NET 6 application in Azure DevOps, and they want to collect and view code coverage results in the build pipeline summary. They have already configured unit tests using MSTest. Which approach should you recommend to ensure code coverage is properly collected and displayed in the pipeline summary?

  1. A

    Use the .NET Core CLI� �dotnet test� command with /p:CollectCoverage=true, then publish code coverage results separately using a Cobertura or JaCoCo compatible format.

  2. B

    Skip the separate code coverage collection and rely solely on raw log outputs from �dotnet test�.

  3. C

    Enable code coverage by setting the �codeCoverageEnabled� property to true in the �Visual Studio Test� task YAML configuration.

  4. D

    Use a separate SonarQube analysis task without including any built-in Azure DevOps test tasks.

Show answer and explanation

Correct answer: C

Explanation

To display code coverage results in the Azure DevOps build pipeline summary when using MSTest, the Visual Studio Test task with the 'codeCoverageEnabled' property set to true provides an out-of-the-box solution. The pipeline will automatically generate, collect, and publish coverage results. For more information, refer to Microsoft� documentation on code coverage (https://learn.microsoft.com/azure/devops/pipelines/test/review-code-coverage-results).

  • A. Incorrect.

    Option 1: While it is possible to collect coverage using �dotnet test� with the /p:CollectCoverage=true parameter, you must also ensure the results are properly published so Azure DevOps can display them. This can be a valid approach if you add a PublishCodeCoverageResults task in your pipeline to display the data in the summary. However, by itself, simply collecting coverage in .NET Core does not guarantee the results will appear in the pipeline summary without additional configuration.

  • B. Incorrect.

    Option 2: Relying on raw log outputs means code coverage data will not be parsed or displayed in an organized way in the build summary. This does not fulfill the requirement of having an integrated view of coverage in the pipeline summary.

  • C. Correct.

    Option 3: Setting �codeCoverageEnabled� to true in the Visual Studio Test task is the simplest way to enable coverage, automatically generate the coverage report, and have the results displayed directly in the Azure DevOps pipeline summary. This is the recommended out-of-the-box approach for MSTest projects.

  • D. Incorrect.

    Option 4: Using SonarQube can analyze coverage, but the SonarQube tasks alone do not automatically publish coverage data to the pipeline summary. You also need a build or test task that collects coverage metrics first. Therefore, SonarQube by itself does not solve the immediate requirement of displaying coverage results in the pipeline summary.

Timed practice exam

Take a AZ-400 practice test under exam conditions

70 questions in 90 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam