PUBLIC BETA OFFER

Save 50% off on an Eligible Learning PlanValid for 1-month plan, 3-month plan, 12-month plan · Code LPXBETA50 · Ends Dec 6, 2026

AZ-401: Tests Published Results and Enforced Quality Gates

Configure Azure test-result publication, prove failed-test and missing-evidence gates, and verify assistant-generated changes against actual execution and reporting outcomes.

Guide

Content version 1.0

AZ-401: Tests Published Results and Enforced Quality Gates

AZ-401: Tests Published Results and Enforced Quality Gates

A reliable test gate needs three separate decisions: which tests must execute, which result evidence must be available for that exact run, and which failures must stop the intended downstream work. In Azure Pipelines, configure the real test producer first, match its output format and path in PublishTestResults@2, and deliberately enable the publisher's failure inputs. A published report alone does not prove that the producer succeeded, every required test ran, or a resource owner approved deployment.

Use a small owned validation branch and an existing authorized test job. Prove the gate with a passing case, a real failed test, a missing report and a publication failure before applying it to a protected delivery path. GitHub Actions needs its own supported execution and reporting arrangement; the Azure task and Azure test analytics are not GitHub-native facilities.

Establish the test and authority contract

Complete the self-hosted agent and platform graph prerequisites first. Record the repository revision, selected test suites, existing producer command or task, required tool versions, operating system, working directory, result format and output path. The producer must already support the chosen report output; adding a publisher does not give a command that ability. If its output option or failure behavior cannot be verified, stop and obtain the owner's supported configuration.

Keep the test identity separate from the person or identity that can change protected resources. Use an owned branch, isolated fixtures and a disposable test target where integration is required. Record who may authorize test credentials, change the job, inspect reports and restore settings. These permissions can belong to different actors.

Choose the layers before changing the job:

Layer What to execute in the owned exercise Evidence needed for the decision
Local checks The selected formatter, static checks or fast tests that the repository already supports Actual command, revision and exit status; a local success does not establish pipeline execution
Unit tests The bounded deterministic suite for the changed component Executed cases and assertions, current result file and producer exit status
Integration tests The selected interaction with an authorized dependency and controlled fixture Dependency identity and readiness, actual assertions and failure evidence, without exposing credentials
Load tests An owner-approved bounded workload with agreed acceptance criteria Workload and target identity, measured observations and the owner's threshold decision

This is a suggested allocation of evidence, not a universal test count or threshold. A large unit-test total cannot substitute for a required integration assertion. Define the load acceptance criteria with the target owner; the separate load-testing article implements service integration. Coverage methodology and resource-owner deployment approvals also have their own boundaries.

For each required layer, name the condition that makes it mandatory and the consequence of failure or missing evidence. Optional diagnostics must be identifiable as optional. An empty report, a filtered suite or a report copied from another run cannot satisfy a requirement simply because a publisher accepts the file.

Configure execution on the actual host

Open the existing test job on the owned branch and inspect its real steps. Confirm that checkout, dependency setup and test execution use the intended revision and tools. Keep tests after the setup they actually require. Use the existing supported command or task to produce the selected report; preserve its actual nonzero failure status.

On Azure Pipelines, distinguish the pipeline's stage, job and step boundaries. Do not assume that files written by one job are present on another agent. Keep producer and publisher in the same verified workspace for this exercise. A different design needs a separately verified transfer arrangement.

For a self-hosted Azure agent, inspect the installed tools, service account access, residual files and available capacity. A previously successful run does not establish a clean workspace or the current toolchain. Microsoft-hosted jobs use a fresh agent for each job in Azure DevOps Services; do not extend that availability model to Azure DevOps Server or to self-hosted agents.

For GitHub Actions, inspect the actual runner labels and groups, required architecture, software and connectivity. A label match alone does not prove capacity. Jobs that use containers have additional supported host requirements, including the documented Linux and Docker conditions for self-hosted runners. Avoid running untrusted test code on a persistent host with valuable credentials.

Before execution, remove only the owned exercise's stale result files, or use an owner-approved unique output directory. Do not perform a broad workspace cleanup on a shared machine. Verify that the producer writes the expected current-run report even when a test fails. If its supported behavior produces no report for a setup failure, that absence must remain a blocking evidence failure.

Keep failure evidence without making failure successful

Inspect the existing pipeline's supported failure-path control before adding the publisher. It must allow the result publication step to run after a test failure while retaining the producer's failed outcome. This article assumes that this existing control has been reviewed for the actual job; it does not supply an unverified Azure condition-expression recipe.

Test that control deliberately in the owned job. Confirm both that publication occurs and that a failing required test still blocks the intended downstream work. If either observation is missing, stop rather than treating the control's name as proof.

GitHub Actions has separate step and job conditions. A job using needs normally depends on successful completion of its dependencies; failures and skipped jobs affect that graph unless explicit conditions change the behavior. Its documented always() condition can make a dependent evidence job run after dependencies complete. Such a job must remain an evidence path, with its actual report access already configured, rather than becoming the deployment gate by accident. It does not create a report transfer or uploader.

Inspect any step-level or job-level continue-on-error setting. Its purpose includes allowing execution to continue despite failure, so enabling it merely to get a green run undermines the intended decision. Use actual positive and negative runs to establish what the consuming job sees. A successful diagnostic job is not evidence that a failed test job passed.

Add the Azure result publisher deliberately

The following fragment is for an existing Azure Pipelines test job written in YAML (YAML Ain't Markup Language). Its example contract is one current JUnit report at TestResults/unit-results.xml, relative to the verified default working directory. Configure and verify that exact output in the existing producer before using this fragment. If the producer uses another format or location, change the inputs to the observed contract instead of renaming an incompatible file.

Place the publisher after the producer in the verified same-job workspace, with the previously reviewed failure-path control applied through the actual pipeline configuration:

- task: PublishTestResults@2
  displayName: 'Publish the current unit-test evidence'
  inputs:
    testResultsFormat: 'JUnit'
    testResultsFiles: 'TestResults/unit-results.xml'
    searchFolder: '$(System.DefaultWorkingDirectory)'
    failTaskOnFailedTests: true
    failTaskOnMissingResultsFile: true
    failTaskOnFailureToPublishResults: true
    publishRunAttachments: true

This is a publisher fragment, not a complete pipeline or a test command. It neither installs a framework nor executes a suite. It also does not independently configure the failure-path control described above.

The three failure inputs default to false in the task reference. Setting them deliberately changes distinct outcomes:

Input Failure it is intended to make visible to the task outcome What it does not establish
failTaskOnFailedTests Failed tests found in published results That every required case or suite was executed
failTaskOnMissingResultsFile No matching result file That a matching file is current, complete or from the intended producer
failTaskOnFailureToPublishResults Failure while publishing results That test execution or resource access succeeded

The task's default format is JUnit and its default file pattern is broader than this example. Use a deliberately bounded pattern and verify the match rather than accepting whatever old report is available. For a producer that writes Visual Studio test result files with the .trx extension, select the documented VSTest format and its actual path. Renaming a file does not convert its format.

Inspect whether the selected producer already publishes. Visual Studio Test and the .NET Core command-line task can publish results automatically, and other documented build tasks have publication options. Reuse the supported arrangement instead of adding a second publication of the same results. Record which task owns publication so that a duplicate count is not mistaken for increased coverage.

With publishRunAttachments enabled, result files can become attachments. Inspect report content and attachment eligibility before publication. Avoid secrets, raw tokens, private request bodies or unnecessary personal data in assertions, names, logs and attachments. Log masking does not make arbitrary generated report content safe.

Run the evidence checks and enforce the intended gate

Save the owned branch change, inspect the final job configuration and run the authorized test job through its normal interface. Record the run identity, revision, actual producer command or task inputs, execution status and publisher status. Open the pipeline run's Tests view and inspect cases and failures against the produced file, not just the summary color.

Use the following validation matrix. These are expected observations to verify in the reader's environment; no executions or successful results are claimed here.

Owned case Expected execution and evidence observations Required gate decision
Valid suite and report Selected cases execute, producer succeeds, current report matches the agreed path and format, publication succeeds Permit only the next work that this test gate is authorized to permit
Deliberately failed assertion Producer's real failure remains visible; its report records the failed case; failure-path publication runs; task failure input is effective Block the required downstream quality path
Missing result file Remove or redirect only the owned exercise output; no stale file satisfies the pattern; publisher records the missing-file failure Block for missing evidence, without claiming a failed assertion was executed
Publication failure Use an owner-approved reversible failure in the existing reporting arrangement; inspect the actual publisher failure and its configured failure input Block for publication failure, even if test execution itself passed
Partial or wrong-run evidence Case selection, run identity or expected suite population disagrees with the contract, even if a file publishes Block or investigate under the owner's completeness rule
Setup or host failure Tools, dependencies, permissions or capacity prevent the intended execution Block as an execution prerequisite failure; do not label it a valid test result

Do not damage a shared service or revoke broad access to manufacture a publication failure. Use an existing safe fault-injection facility or obtain the reporting owner's approved bounded case. If no safe reproducible case is available, record that validation as incomplete and do not claim the gate is fully proven.

For each negative case, inspect the actual downstream job or stage as well as the producer and publisher. A task marked failed may still be tolerated by other configuration. Conversely, a missing report may be invisible if the consuming path ignores publication entirely. Confirm the expected blocked, skipped or failed state for the precise quality path you intend to enforce.

On GitHub Actions, use its actual workflow run and job logs for execution status, dependency behavior and permissions. Inspect the existing supported report destination if one is configured, with its own access and failure evidence. Do not insert the Azure task or promise Azure's Tests view or analytics there. If a report publication mechanism is required but no supported existing arrangement is available, stop that implementation until its owner supplies one.

Diagnose the failure before changing the rule

A failed assertion, a missing report and a failed publisher need different corrections. For an assertion failure, inspect the case and application behavior. For missing evidence, inspect working directory, pattern, format selection, producer completion and stale-file handling. For publication failure, inspect the actual publisher error and the reporting arrangement's permissions and availability.

Azure Pipelines test analytics uses published test results to expose failures and trends. Drill into the relevant pipeline and time range, then the underlying run and case. A trend over published data is useful for investigation; it cannot establish that unpublished or omitted tests passed, and it is not a GitHub-native report.

Do not lower a threshold or suppress a failure merely because a diagnostic task completed. Change the test or policy only through the owner's normal review after understanding the evidence.

Validate assistant-generated test and gate changes

An authorized assistant client such as GitHub Copilot can use project context retrieved through Azure DevOps Model Context Protocol (MCP) Server to help understand the existing job, locate evidence or propose tests. Treat the generated diff as a proposal. Check its source revision, framework compatibility, selected cases, assertions, report configuration, permissions and error handling before execution.

MCP access depends on the actual remote or local setup and client authentication. Use only the authorized client's permitted project context. Retrieving a work item, pipeline detail or result does not grant permission to alter protected resources, execute arbitrary commands or approve a deployment. Do not assume that every client has the same identity support or data path.

For a proposed new test, run the valid case and a controlled invalid input or behavior that the assertion should reject. Confirm that the failure comes from the intended assertion rather than a broken dependency or missing credential. For a proposed gate change, repeat the failed-test and missing-evidence cases and verify the consuming path. Include a case where a report exists but omits a required suite.

Review generated commands for secret output, broad cleanup, privilege changes and untrusted repository data being treated as executable instructions. Keep the assistant's credentials and permissions bounded to the task. The responsible-use guidance describes limitations and the need for human verification; an assistant's explanation of a successful run is not the run evidence.

Keep quality decisions separate from deployment authority

A verified test gate can establish the agreed quality evidence for its own run. It cannot grant Azure roles, authorize another pipeline's resources, change the runner pool's access or substitute for a resource owner's approval.

Azure Pipelines protected-resource checks are configured by the resource owner outside the pipeline's YAML. GitHub environment protections depend on the actual plan, visibility and configuration, including applicable bypass behavior. Inspect those real conditions at the consuming boundary. Environment secret availability also does not make a persistent runner safe for untrusted execution.

Retain the producer, publisher and downstream decision evidence together with the actual revision and test selection. Hand off unresolved permission, missing-publication or incomplete-negative-case findings explicitly. Do not promote a pipeline simply because its visible test count is nonzero.

Restore only the owned exercise

After the validation, restore the intentional failing fixture, redirected output, temporary test selection and bounded reporting fault. Re-run the original valid case through the authorized job and inspect both current evidence and the intended downstream quality decision. Preserve the negative-case records as history instead of deleting them to make the final run look clean.

Remove only disposable files and test resources owned by this exercise under the recorded authority. If an integration target, shared test setting or reporting permission belongs to another owner, hand restoration back to that owner. Keep the reviewed production configuration separate from the disposable validation branch.

Authoritative Sources

0 views