AZ-400 Question 27
Select 2Your DevOps team needs to measure code coverage trends and identify the most frequently failing unit tests in a .NET project. You plan to build an interactive dashboard in Azure DevOps to regularly surface these metrics for the development team, so they can prioritize refactoring efforts. Which two actions should you take to achieve this goal?
- A
Publish test results and code coverage from your build pipeline to Azure DevOps, then use an Analytics view to create dashboards tracking coverage over time.
- B
Configure a Quality Gate in SonarQube (or SonarCloud) to measure code coverage and failing tests, then integrate the results with your Azure DevOps dashboard.
- C
Define custom queries in Azure Boards that filter Work Items by code coverage threshold and failing tests, and pin these queries to a dashboard.
- D
Create a release pipeline that automatically rolls back if a single test fails in the last execution of the build pipeline.
- E
Use Azure Application Insights to capture code coverage metrics by adding coverage counters in the application� telemetry code.
Show answer and explanation
Correct answers: A, B
Explanation
Using Azure DevOps build tasks to publish test results and coverage data (Option 1) and incorporating SonarQube (Option 2) are proven ways to gather and display these metrics in an Azure DevOps dashboard. Microsoft� documentation (docs.microsoft.com/azure/devops/report/analytics) covers creating analytics views to trend test results and coverage data over time. SonarQube or SonarCloud integration is also well-documented (docs.sonarqube.org/latest/analysis/azuredevops) for adding code coverage and quality gates to your DevOps process.
- A. Correct.
Option 1 is correct. You can publish both test results and code coverage from tasks in your build pipeline (e.g., the .NET Test task) into Azure DevOps. By creating an Analytics view, you can track coverage trends over time and pin charts to a dashboard. This approach is well-documented under Azure DevOps Analytics features.
- B. Correct.
Option 2 is correct. SonarQube or SonarCloud can calculate code coverage and detect failing tests. A Quality Gate can be configured to fail the build if coverage is below a certain threshold. You can then integrate SonarQube with Azure DevOps to display these metrics on dashboards, providing a clear view of coverage and test failures.
- C. Incorrect.
Option 3 is incorrect. Azure Boards queries primarily focus on Work Items. While you can create queries for bug or task tracking, there is no direct way to filter code coverage thresholds or failing tests through Boards queries alone.
- D. Incorrect.
Option 4 is incorrect. Although you could enforce quality in a release pipeline, automatically rolling back every time a single test fails can create false positives and disrupt the pipeline. More nuanced criteria or a build-level quality gate is typically preferred.
- E. Incorrect.
Option 5 is incorrect. Application Insights is intended for application telemetry (e.g., performance, request logs), not code coverage tracking. There is no built-in mechanism for capturing code coverage data via Application Insights.