AZ-400 Question 119
Select 2You maintain a .NET Core application whose tests are triggered by an Azure DevOps YAML pipeline. After configuring a .NET Core test task, you notice that pass/fail outcomes and code coverage data are not appearing in the pipeline summary. Which two actions should you take to ensure full integration of test results and coverage data?
- A
Add a 'Publish Test Results' task in the pipeline specifying the correct test result format (e.g., 'trx').
- B
Use a self-hosted agent with the 'Test Runner' capability enabled in Azure DevOps.
- C
Include the '--collect "Code Coverage"' parameter in the .NET Core test command to capture coverage metrics.
- D
Create a pipeline variable named 'EnableCoverage' set to 'true' in the variable group to publish code coverage results.
Show answer and explanation
Correct answers: A, C
Explanation
To integrate test results and code coverage with an Azure DevOps pipeline, you should generate coverage data with the appropriate command line parameter (for example, using '--collect "Code Coverage"' in .NET Core) and then publish that data with the 'Publish Test Results' task in your YAML or classic pipeline. Refer to the Microsoft documentation on Azure Pipelines test and code coverage tasks (https://docs.microsoft.com/azure/devops/pipelines/test/) for detailed guidance on properly configuring and publishing test outcomes.
- A. Correct.
Option 1 is correct. You must explicitly publish test results so they appear in the pipeline summary. The 'Publish Test Results' task (or the equivalent YAML step) identifies and publishes test outcomes for easier review.
- B. Incorrect.
Option 2 is incorrect. While a self-hosted agent may be used for more control or to match certain capabilities, there is no specific 'Test Runner' capability you must enable to display test outcomes. The standard capabilities for .NET or Visual Studio are typically sufficient.
- C. Correct.
Option 3 is correct. Passing the '--collect "Code Coverage"' parameter to the .NET Core test command ensures that coverage data is generated. Without it, coverage metrics are not collected and cannot be shown in the pipeline summary.
- D. Incorrect.
Option 4 is incorrect. Simply creating a variable named 'EnableCoverage' will not automatically publish coverage results. Proper configuration of the test task or command line parameter is required.