xunit / visualstudio.xunit

VSTest runner for xUnit.net (for Visual Studio Test Explorer and dotnet test)
https://xunit.net/
Other
144 stars 81 forks source link

Add ability to print live output messages in Test Explorer/`dotnet test` output #408

Closed bradwilson closed 4 months ago

bradwilson commented 4 months ago

This adds the ability to show output messages in real time, which may assist in debugging a test which is long-running.

bradwilson commented 4 months ago

Available in 2.8.1-pre.4 https://xunit.net/docs/using-ci-builds

Documentation has been updated on enabling this feature:

Using this example test:

using Xunit;
using Xunit.Abstractions;

namespace Empty;

public class TestClass(ITestOutputHelper helper)
{
    [Fact]
    public void TestMethod()
    {
        helper.WriteLine("This is a line of output");
    }
}

Output for dotnet test requires passing --logger console;verbosity=normal to that VSTest does not hide the output from xUnit.net:

image

Output for Test Explorer is in the Output Window, under the Tests tab:

image

Piedone commented 4 months ago

That was quick, thank you!

Piedone commented 4 months ago

Is there any reason not to always enable this, at least in CI? Does it have a noticable impact on performance, for example?

bradwilson commented 4 months ago

There should be no significant performance impact. It's not enabled by default because it's really a debugging tool more than anything else, and live printing output messages makes the output significantly more cluttered (especially with tests running in parallel that are all outputting messages).

Piedone commented 4 months ago

I see, thanks.