Publishing xunit test results in Azure Devops fails with "No Result Found to Publish"
Asked Answered
D

2

14

I want to publish xunit test results in an Azure Devops release pipeline using the "Publish test results" task Version 1.* and 2.*.

Although xunit test file is present and has content - I checked with ls and cat commands in the pipepline I get an error message like this:

2020-02-13T08:23:10.9093662Z Obtained XUnit Test Run Start Date: 2020-02-13T08:23:10.9092530Z and Completed Date: 2020-02-13T08:23:10.9092530Z
2020-02-13T08:23:10.9144214Z No Result Found to Publish '/home/vsts/work/r1/a/report/report.xml'.
2020-02-13T08:23:10.9149123Z Obtained XUnit Test Run Start Date: 2020-02-13T08:23:10.9148260Z and Completed Date: 2020-02-13T08:23:10.9148260Z
2020-02-13T08:23:10.9149993Z No Result Found to Publish '/home/vsts/work/r1/a/report/report1.xml'.

The two files report1.xml and report2.xml get discovered properly but Azure DevOps says No Result Found to Publishand hesitates to publish them.

Dailey answered 13/2, 2020 at 8:44 Comment(3)
Hi, which test task do you use to run the xunit test? Since this task supports xunit v2 not v1, please check which version of xunit do you use.Afrikander
I tried both variants. No difference.Dailey
There's also this issue which suggests a possible issue and fix, although it did not work for me: github.com/microsoft/azure-pipelines-tasks/issues/12772Moist
D
6

I found a workaround to the problem which does not really solve the xunit publish issue but I can live with that.

The Xunit test result I would like to publish is from a testcafe runner which has many reporting possibilities. I switched to testcafe-reporter-junit and exported a junit test report. Then using the test publisher for junit files and everything works.

Since switching to VSTest also resolved it maybe it is just the xunit test publisher which has an issue.

Dailey answered 15/2, 2020 at 6:20 Comment(3)
I had the same issue, but got it working by using JUnit in Azure DevOps task and XUnit in robot framework output format.Fearful
I tried the other fixes with VSTest (see above) but those made no difference. This fixed it. (a) switch to JUnit reporter; (b) set extension to xml, (c) pipeline testResultsFormat: 'JUnit'. Job done.Moist
My xunit.xml was generated by the Robot Framework and simply switching the 'Test result format' to JUnit in the Publish Test Results task worked for me too.Pulsar
A
13

If you're using dotnet test task in this way:

enter image description here

You may need to set VSTest instead of Xunit in Publish Test Result Task:

enter image description here

I met same message like yours and then resolve it by changing Xunit to VSTest. I think you may encounter similar issue.

In addition:

And as I know, built-in tasks such as Visual Studio Test task and Dot NetCore CLI task automatically publish test results to the pipeline, so you actually don't need a separate Publish Test Results task in the pipeline. See this for more details.

E.g: Dotnet test task by default will generate and publish test results:

enter image description here

Hope it makes some help :)

Afrikander answered 14/2, 2020 at 8:52 Comment(1)
Should be marked as answer.Valorie
D
6

I found a workaround to the problem which does not really solve the xunit publish issue but I can live with that.

The Xunit test result I would like to publish is from a testcafe runner which has many reporting possibilities. I switched to testcafe-reporter-junit and exported a junit test report. Then using the test publisher for junit files and everything works.

Since switching to VSTest also resolved it maybe it is just the xunit test publisher which has an issue.

Dailey answered 15/2, 2020 at 6:20 Comment(3)
I had the same issue, but got it working by using JUnit in Azure DevOps task and XUnit in robot framework output format.Fearful
I tried the other fixes with VSTest (see above) but those made no difference. This fixed it. (a) switch to JUnit reporter; (b) set extension to xml, (c) pipeline testResultsFormat: 'JUnit'. Job done.Moist
My xunit.xml was generated by the Robot Framework and simply switching the 'Test result format' to JUnit in the Publish Test Results task worked for me too.Pulsar

© 2022 - 2024 — McMap. All rights reserved.