AZ-400 Practice Question: Design and implement build and release pipelines
Your team uses Azure Pipelines to build a Node.js application. The build pipeline runs linting, unit tests, and creates a production build. You want to ensure that the pipeline fails if the test coverage drops below 80%. You need to implement this check. What should you do?
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
✓
Add a 'Publish Test Results' task with code coverage enabled, then use a 'Script' task that reads the coverage report and fails if below 80%.
The 'Publish Test Results' task can publish code coverage reports, and a subsequent script task can parse the report (e.g., using a tool like c8 or nyc) and exit with a non-zero code if coverage is below 80%, causing the pipeline to fail. Option A is incorrect because a pipeline variable alone cannot enforce coverage thresholds; you need a task that checks the coverage. Option B is incorrect because branch policies can enforce code review requirements but not specific code coverage percentages from build results. Option C is incorrect because the 'Visual Studio Test' task is designed for .NET applications, not Node.js; it does not work with Node.js coverage reports.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Configure a pipeline variable 'CoverageThreshold' and use it in a gate.
Why it's wrong here
Pipeline variables are inert key-value pairs, not executable checks. A variable such as 'CoverageThreshold' could hold a numeric value, but a pipeline 'gate' is a release/deployment approval concept that cannot evaluate a variable against a test-coverage report. Without a task that reads the coverage report and compares it to the variable, this option does nothing to enforce the 80% threshold.
- ✗
Set a branch policy that requires code coverage to be at least 80%.
Why it's wrong here
Azure Repos branch policies can require a PR to have a linked work item, a successful build, or a minimum number of reviewers, but they do not include a code coverage requirement. Coverage thresholds are runtime build checks, not repository-level policy settings, so this option is not available in the Azure DevOps UI.
- ✗
Use the 'Visual Studio Test' task with code coverage enabled and set the 'Minimum coverage' option.
Why it's wrong here
The Visual Studio Test task, designed for .NET test frameworks, does not expose a 'Minimum coverage' option; it only has a code-coverage enabled toggle. Even when enabled, the task publishes coverage data but never fails the build based on a coverage percentage. For a Node.js app, this task is irrelevant because it does not run JavaScript test runners like Jest or Mocha.
- ✓
Add a 'Publish Test Results' task with code coverage enabled, then use a 'Script' task that reads the coverage report and fails if below 80%.
Why this is correct
This is the correct pattern: the Publish Test Results task accepts coverage output (e.g., Cobertura XML from Istanbul/nyc) and publishes it to the pipeline, and then a subsequent Script task (PowerShell, Bash, etc.) parses the generated report—such as reading the 'coverage-summary.json' or the Cobertura XML—and explicitly fails the build if the line coverage is below 80%. This gives you arbitrary custom logic to enforce the threshold exactly as required.
Go deeper
Related to this question
Learn chapter
Introduction to DevOps and Azure DevOps
Key term
Check
A Check in Azure DevOps is a gating mechanism that evaluates predefined conditions before allowing a pipeline deployment to proceed to a specific environment.
Key term
Task
A Task in Azure DevOps is a predefined, reusable step that performs a specific action during a build or release pipeline, like compiling code or running tests.
About these practice questions
This AZ-400 question is part of Courseiva's 823-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.