Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bradwilson opened this issue May 3, 2024 · 10 comments

Comments

@bradwilson
Copy link
Member

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

@bradwilson
Copy link
Member Author

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
Copy link

Piedone commented May 10, 2024

That was quick, thank you!

@Piedone
Copy link

Piedone commented May 10, 2024

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

@bradwilson
Copy link
Member Author

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
Copy link

Piedone commented May 10, 2024

I see, thanks.

@NicolasDorier
Copy link

So with this PR, console;verbosity=normal is showing the output whether the showLiveOutput is true or false.

showLiveOutput is only deciding whether the logs are showing in real time or not. It isn't deciding whether the logs should be shown at all.

This is problematic, the test output is now difficult to read.
I would expect console;verbosity=normal to, like before, only show whether test pass or not. With the stacktrace if it didn't pass.

Dropping verbosity one level down remove the Passed logs.

@bradwilson
Copy link
Member Author

We don't have that level of control. The verbosity from dotnet test is under the control of VSTest, and we don't even know when/if you change that verbosity.

I don't particularly consider "the logs got harder to read" to be a huge problem, since this is intended to be temporarily enabled to help find tests which are running over time and potentially never ending. This is not intended to be permanently enabled.

@NicolasDorier
Copy link

NicolasDorier commented Dec 2, 2024

@bradwilson This is not intended to be permanently enabled.. I understand this, but my point is that even if you disable it, it prints the logs (not in real time), when before, it didn't.

Basically I don't want to see logs if with console;verbosity=normal and showLiveOutput=false.

If I want to debug, turning showLiveOutput=true works as expected.

@bradwilson
Copy link
Member Author

Basically I don't want to see logs if with console;verbosity=normal and showLiveOutput=false.

Disable diagnostic messages.

@NicolasDorier
Copy link

Damn, didn't noticed I had that on... this fixed it thanks. Sorry for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants