Closed robrich closed 4 months ago
Could you share the log.*
files generated with dotnet test --diag:log.txt
command?
Which version of xunit logger and which OS? I will try to repro this.
I'll go one better. https://github.com/robrich/xunit-logger-bug-repro is a repository that nicely reproduces the error. I've seen it fail both on ubuntu-latest Azure DevOps runner and on Windows 11.
@robrich thanks, the repro project was super helpful :+1:
Both Junit logger and Xunit logger depend on the Spekt.Testlogger project. And both are using different versions of the testlogger. Xunit logger uses the latest version with coverage capabilities.
When the test project has both test logger references, MSBuild copies both logger's Spekt.TestLogger.dll to the OutputDirectory; however arbitrarily only one Spekt.TestLogger.dll. When Junit's copy of testlogger.dll remains, Xunit logger fails to emit a test result with above stacktrace.
Workaround: removing Junit logger reference from the test project fixes the issue. Does this unblock your scenario?
The fix will require a new release for Junit with latest testlogger version.
Yes, removing the reference to jUnit did solve the symptoms. Thanks also for the PR to the jUnit project to get it up-to-date too.
Given:
Works as expected:
I now have a
test-results/unit-result.xml
file right next to my solution. I have no code coverage details, but I haven't asked for any.Doesn't work:
I have a
test-results/*/coverage.*.xml
but notest-results/unit-result.xml
file. (I find it curious that--results-directory
is relative to the current working directory andLogFilePath
is relative to the csproj, but that's a problem for another day.)Does work:
I have both
test-results/unit-result.xml
andtest-results/*/coverage.*.xml
. Note that in this case I'm /not/ using xUnit, I'm using jUnit instead.