Azure Pipelines: "No test result files matching ... were found"
The Publish Test Results task found no file that matches its pattern, so the run has no test results, and the task only warns: the run can be green with no tests reported. The pattern, the format or the folder doesn't match the file your test step wrote, or the test step wrote none.
What the task looks for by default
| Input | Default | Change it when |
|---|---|---|
testResultsFiles | **/TEST-*.xml | Your file is named otherwise, for example **/*.trx or **/junit.xml |
testResultsFormat | JUnit | The file is TRX (VSTest), NUnit, xUnit or CTest |
searchFolder | $(System.DefaultWorkingDirectory) | The file is written outside the sources, for example under $(Agent.TempDirectory) |
failTaskOnMissingResultsFile | false | You want a failed task instead of a warning |
From Microsoft's reference for PublishTestResults@2.
When the tests run as a pull request's build validation: Azure DevOps Pull Requests, a plugin for JetBrains IDEs, lists the pull request's branch policies with their state in IntelliJ IDEA, Rider or PyCharm, and with Pro runs a failed build policy again once the tests are fixed. Its Pipelines tab (version 1.0.86 and later) lists the runs of the repositories you have open and opens a failed task's log in the editor, free to read.
The usual causes
- The .NET Core task already published them.
DotNetCoreCLI@2withcommand: testhaspublishTestResults: trueby default: it adds--logger trx --results-directory $(Agent.TempDirectory)and publishes that TRX file itself (.NET Core task). A Publish Test Results step after it, with the default folder, finds nothing. Remove it, or point it at$(Agent.TempDirectory)with**/*.trxandVSTest. - The pattern and the format don't match the tool. The default fits JUnit files named
TEST-*.xml, the way Maven Surefire names them. A TRX, NUnit or xUnit file needs both its own pattern and its own format. - The tests ran in a container. In a multi-stage Dockerfile the tests run inside the image, and the results stay there unless you copy them out to the agent, as Microsoft's reference notes.
- The test step failed before it wrote anything. Then the warning is a side effect; the error is in the test step's log. Run the publish step with
condition: succeededOrFailed()so it still runs after failed tests.
Find the file
- bash: find "$(System.DefaultWorkingDirectory)" "$(Agent.TempDirectory)" -name "*.trx" -o -name "TEST-*.xml" -o -name "*.junit.xml"
condition: succeededOrFailed()
Put it right after the test step, and copy the path it prints into searchFolder and testResultsFiles. Then set failTaskOnMissingResultsFile: true, so a missing file fails the run instead of passing quietly.
Similar pages
- "Dotnet command failed with non-zero exit code": a failed test step of the .NET Core task.
- "Bash exited with code 1": a failed script step, and keeping the test results published after it.
Azure DevOps pull requests in IntelliJ IDEA, Rider and PyCharm
Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, reads the organization, project and repository from your git remote and lists the pull requests that wait for your review in an IDE tool window, on Azure DevOps Services and on Azure DevOps Server. It shows the branch policies of a pull request with their state, so a required build that has not passed is next to its pull request, and with Pro you run a failed or expired build policy again from there. The review inbox is free; voting, commenting, completing and creating are Pro, with a 30-day trial.
Get it on JetBrains Marketplace
Azure DevOps and Azure Pipelines are trademarks of Microsoft Corporation; IntelliJ IDEA, Rider and PyCharm are trademarks of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.
More: Dotnet command failed with non-zero exit code · Bash exited with code · Build validation · 日本語