AZ-400 Practice Question: Design and implement build and release pipelines
You are designing a pipeline to build a .NET Core application. The build must run unit tests and publish code coverage results. Which task should you use to publish the code coverage results to Azure DevOps?
⚠ Common exam trap
Many exam-takers confuse the task that runs tests with coverage collection (e.g., VSTest@2 or DotNetCoreCLI@2) for the task that publishes the coverage results, forgetting that publishing is a separate, explicit step required to surface the data in Azure DevOps.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use the 'PublishCodeCoverageResults@1' task.
The 'PublishCodeCoverageResults@1' task is the correct choice because it is specifically designed to publish code coverage results (e.g., Cobertura or JaCoCo XML reports) to Azure DevOps, making them visible in the build summary and pipeline artifacts. This task consumes the coverage data file generated by a previous test run (e.g., via 'DotNetCoreCLI@2' with '--collect "Code Coverage"') and uploads it to the Azure DevOps service for reporting.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use the 'PublishCodeCoverageResults@1' task.
Why this is correct
The PublishCodeCoverageResults@1 task is the dedicated Azure DevOps task for publishing code coverage data generated by test runs to the pipeline UI and build summary. It accepts coverage files in formats like Cobertura or JaCoCo, making it the correct choice for publishing .NET Core coverage reports.
- ✗
Use the 'PublishTestResults@2' task.
Why it's wrong here
The PublishTestResults@2 task publishes test result files (e.g., TRX, JUnit, NUnit) to Azure DevOps for test analytics and failure reporting, but it does not process or publish code coverage data. Coverage results require a separate task, PublishCodeCoverageResults@1, so this option is incorrect for the stated goal.
- ✗
Use the 'DotNetCoreCLI@2' task with the 'test' command.
Why it's wrong here
The DotNetCoreCLI@2 task with the 'test' command runs 'dotnet test' and can generate coverage files if you specify '--collect:"XPlat Code Coverage"', but it only produces the coverage output on disk. It does not publish those results to Azure DevOps; you must subsequently use PublishCodeCoverageResults@1 to upload and report them.
- ✗
Use the 'VSTest@2' task with the 'codeCoverageEnabled' option.
Why it's wrong here
The VSTest@2 task is intended for running tests via the Visual Studio Test Platform (vstest.console.exe) and its 'codeCoverageEnabled' option collects .coverage binary files for classic .NET Framework scenarios. However, for .NET Core applications, the standard practice is to use DotNetCoreCLI@2 with coverage collection and then publish the results with PublishCodeCoverageResults@1, making this option incorrect.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
XML
XML is a flexible text format used to store and transport data in a way that both humans and computers can read, using custom tags to describe the data's structure.
Key term
Pipeline
A pipeline is an automated series of steps that takes code from development to production, ensuring quality and speed.
About these practice questions
Courseiva writes every AZ-400 question from scratch — 823 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.