-
Notifications
You must be signed in to change notification settings - Fork 106
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
Console.WriteLine() does not write to console when runningdotnet test
#343
Comments
Any workaround for this for now? |
Sorry, nothing yet. |
This makes showing the errors a pain. Microsoft is directing the problem to the test adapter implementers, see: microsoft/vstest#799 |
I am finding that if a test is successful, its console output is not displayed. But if it fails, after the failure message and Stack Trace, the output contains a line "Standard Output Messages:" followed by the console output from that test alone. Is this behaviour deliberate? If so is it configurable? |
Run into same issue as well. See #132 (comment) |
I have the same problem and would like this to be fixed too |
For info, "dotnet test -v n" adds a lot of crap to the console, but at least diplays the stdout lines. |
@scriplit And it is a lot of crap that really just a crap without anything useful |
We can't add to the command line options for |
Same issue... though for me I don't see stdout lines, even with "-v n" flag |
Why does NUnit-3 disable console output? It also seems to disable logging too. Is there a way to make NUnit not do that? |
Even though it can't access |
Try use |
Well 'NUnit.Framework.TestContext.Progress.WriteLine()' could work it is tests which write to console. Bu we have no control of what the application we are testing writes to console. It's still a bug, seems to be trivial to fix, but nobody fixed it in years |
@OsirisTerje should this be up for grabs? Sounds like there's a possibility that this is trivial. |
@jnm2 Anyone can grab this of course. Tip: Enable dump file, and look at what NUnit actually sends to the adapter. Anything going there is sent to the EventListener, and once there it can be sent anywhere. |
Can you please bump the priority of this a bit? Still no progress after nearly a year since the last comment. |
@richardthombs Can you please check this alpha version: https://www.myget.org/feed/nunit/package/nuget/NUnit3TestAdapter/3.17.0-dev-01324 The console output is fixed there. It's part of a rather big refactoring, all tests are green, but if you see something else then just report that. Also ping @ayoung, @cincuranet , @giggio, @sebwills, @dariusdamalakas , @Thaina, @scriplit,@dhowe, @zcyemi,@JustoSenka |
@OsirisTerje have just tested with NUnit3TestAdapter 3.17.0-dev-01324 and I still cannot see Console.WriteLine with dotnet test (on either Windows or Linux). Note that everything seems fine on all IDE test runners (Rider, VS). Repo with the test: https://github.com/roji/TestConsoleTests/ |
@roji Just tried your repo, and I do see the correct output. Changed the console.writeline to say "Hello world from NUnit" and "Hello world from XUnit", and I do see the NUnit output, but not the XUnit output. Please note that you need to have the verbosity set to normal. that is:
|
@OsirisTerje ah I see, thanks - with the verbosity set to normal I can see the message as well. Seems a bit questionable to not write output by default, but I'm guessing that's unrelated to NUnit. |
@roji Agree with the verbosity, that is the dotnet test default that imho should be normal, but for some reason is not. And as you assume, we can't do anything with that from the adapter side. Could be worthwhile an issue at the dotnet repo though. |
Opened dotnet/sdk#10706 |
@roji Beta released on Nuget, see https://www.nuget.org/packages/NUnit3TestAdapter/3.17.0-beta.1 . Please check that it works :-) |
Great! Gave it a try, and I can confirm that I can see Console.WriteLine (when |
I just tried it with |
@giggio Thanks! |
Hi I'm using net5.0, NUnit-3.13.2 and NUnit3TestAdapter-4.1.0 and |
@alfreql Yeah, this is annoying, see dotnet/sdk#10706 . You can get it out doing: dotnet test v n --logger "Console;verbosity=normal" alternatively, if you don't want the logger approach, change your code to use TestLogger.Progress.WriteLine, that will output with just the |
Thanks!!! Also without -v n works (and avoid some verbosity): |
Hmm.... cool and right you are, never tried removing that one :-) That means one could also set the logger in a .runsettings file, see https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022#loggerrunsettings-element and then do dotnet test -s .runsettings The .runsettings would then be: <?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="console" enabled="True">
<Configuration>
<Verbosity>normal</Verbosity>
</Configuration>
</Logger>
</Loggers>
</LoggerRunSettings>
</RunSettings> PS: If you only have the sln file in the folder, you don't need to specify it |
Just to have it said: There is something that happened, because the 3.17 DID output the Console, but right now it doesn't, neither for 3.17 or for 4.X. Not sure what, but I'll look into it. |
This will be fixed in 4.2 |
@ayoung commented on Thu Jun 15 2017
I'm running
dotnet test
targeting netcorapp1.1. Within the test I'm executing a console write but that text never makes it to the output on the screen.@rprouse commented on Fri Jun 16 2017
Are you using
dotnet-test-nunit
or the alpha of the adapter for your tests? In other words,project.json
orcsproj
? This issue needs to be moved to the correct repository.@ayoung commented on Sat Jun 17 2017
i am using the alpha adapter. csproj.
@rprouse commented on Sat Jun 17 2017
Thanks, I am going to move to that repository then. Please track it there.
The text was updated successfully, but these errors were encountered: