2

On .NET Core 8 with xUnit (Abstractions version 2.0) when we write test output to the TestOutputHelper, every line that's written to the output - see screenshot (1) - counts as a "Warning", see screenshot (2), in the Visual Studio 2022 test explorer.

Screenshot of VS Test Explorer with warnings

Is this an oversight from Microsoft to not funnel this into a "Log", "Information" or other non-warning, non-error counter, or are we doing something wrong? There is nothing like a "log level" at play, we are simply calling the void WriteLine(string message) method on the test output helper.

Another sample, here it can be seen that only the first message is actually a warning:

enter image description here

Versions:

  • xunit 2.9.0
  • xunit.runner.visualstudio 2.8.2

This is my xunit.runner.json content

{
    "diagnosticMessages": true,
    "shadowCopy": false
}
1
  • 1
    Can't reproduce. Please add more details; like version of xunit and xunit.runner.visualstudio packages, the xunit.runner.json if present, the .csproj of the test project, etc.
    – pfx
    Commented Nov 21, 2024 at 18:52

2 Answers 2

1
+50

I couldn't reproduce when my test project didn't have a xunit.runner.json file.
After adding one the issue appeared.

As a solution, see if you really need that xunit.runner.jsonfile an remove it.

Otherwise, disable diagnostic messages:

{
  "diagnosticMessages": false,
  "shadowCopy": false
}
2
  • the thing is, without the xunit.runner.json diagnosticMessages setting true, there is no real-time azure devops pipeline test job output. I'm thinking of removing the file from the solution and only writing it in the build pipeline job sandbox. Commented Nov 22, 2024 at 18:41
  • 1
    @CeeMcSharpface I wasn't aware of the Azure Devops context. But I tend to say my answer still stays. Your workaround suggestion in above comment somehow makes sense, since this issue on github more or less explains it's not foreseen as such. But at least, above resolves the issue in the local VS test runner.
    – pfx
    Commented Nov 22, 2024 at 18:55
0

The warnings may very well be a quirk of VS 2022 Text Explorer.

I replicated a similar setup and didn't encounter a warning in JetBrains Rider, VS Code, or from the terminal with dotnet test.

Maybe try either of the above options as well and see if you run into similar warnings?

Not the answer you're looking for? Browse other questions tagged or ask your own question.