-
Notifications
You must be signed in to change notification settings - Fork 323
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 calls during dotnet test are not emitted to the console on Windows #799
Comments
From @krwq on January 5, 2017 23:46 @jonsequitur You should probably be using Xunit's ITestOutputHelper. making Console.WriteLine forward to that might be slightly harder |
From @jonsequitur on January 6, 2017 4:35 The issue that I was seeing was that this works on OS X but not on Windows. |
I am seeing that too on windows. None of the Console.WriteLine from my tests gets printed out. We should not ask users to use special APIs to print to the console. @codito @Faizan2304 Can you guys take a look? I think we should move this bug to the vstest repo. |
I think this should be handled by adapters at some level. MSTest for instance captures and sends the console outputs to the runner, I think we are including them in trx logger, but not in the console. We can start showing them in console. cc: @Faizan2304 There were a few requests to capture console output in xunit: |
Fixed!! |
@Faizan2304 Is it fixed in Visual Studio Community 2017 Version 15.2 (26430.15) Release? I still cannot get the output in the output window or the test explorer. I'm using xunit. |
I also still do not see test output and would love to, please. From
and in csproj:
(I am using preview version of VS and latest dotnet core from github) |
Sorry for the late reply. I missed this thread. @rogusdev : How are you writing output from test method? Is it |
Yes. But @bradwilson said in xunit#1141
So.. could you fix or change the behaviour of VSTest runner to remove the limitaion? |
@zwcloud: Its the responsibility of adapter to fill console.WriteLine message in TestResult.Message. But as you can see, @bradwilson said in xunit#1141 that they are not capturing console output to test result
In this case you have to follow this article. xunit is suggesting to use IOutputHelper to log your message. |
Why the issue is closed if there is still no console output in tests? It's kinda strange to have console test runner which doesn't show console output. |
Bumping this in case anyone else comes along hoping to find an answer.
I learned that running the above will show the "Standard Output Messages:" that you would expect from Console.Write*. It does flood the terminal with information at build but at least is a solution for the time. "-v" is a Verbosity argument. "n" represents "normal". Refer here for more information. I use this with a .NET Core Unit / Integration test projects running NUnit. |
@Faizan2304 Apparently you guys think you have done quite well in handling the console output. But that's far from the truth. We don't want to use IOutputHelper to log your message, just implement a simple way today to get this output from dotnet test directly on the console. |
I solved the problem by letting my xUnit test classes inherit from a base class, that rewires console to ITestOutputHelper. Has some drawbacks since everything is first copied at the end, i.e. not during debugging. Someone can probably improve it.
|
@mattiasw2 nice job! but, it's a bug in dotnet test? |
@alexsandro-xpt Sorry, you are correct, it is related to Xunit, and the reason I ended up here is @Faizan2304 Also, since I did the above, I realized it only works if you do not run tests in parallel. The core problem is actually Console.SetOut, since you would actually want to have a Console.SetOut that only changes the Console in the current thread, something that is hard in dotnet (but easy in Clojure). So. you can delete my comments as not relevant. |
Why is this closed? |
@Faizan2304 this is not working for me using Could you please re-open the issue? This is still broken for many. |
Could this be re-opened? It is clearly not fixed for a very large number of users. The BTW, if anyone is having trouble getting the |
I'm also experiencing this problem on Windows. On Linux, it works just fine. Interestingly, on Appveyor Windows builds, I also see the console output. It's only locally that I see nothing. |
How does appveyor do this? |
Works on Linux/Mac, but not on Windows... |
Any final solution to this problem for Windows? Edit:This is what I ended up doing:
|
On
However, on Windows, I don't see anything. |
@Faizan2304 Why have you closed this? It isn't fixed! 😡 |
@olfek , |
@olfek is correct, this is still broken on Windows for xUnit.net. Windows: Linux (WSL): |
This was closed prematurely @Faizan2304 |
Note that unlike other test frameworks, xUnit.net v2 does not touch or capture Console output. It appears that VSTest on Windows is capturing (and throwing away) Console output, whereas on Linux it is not (or some similar disparity). |
Really annoying, I envy the Linux version. xUnit states on its website https://xunit.net/docs/capturing-output that this funcitonality was intentionally removed due to "many tests [...] running in parallel". Hell! When I want to create and fine tune one test, I just let this one test run, and need some helpful output which I then remove when it's done. |
@IngmarPaetzold u might find this useful https://github.com/SimonCropp/XunitContext/ |
Thanks Simon, good to know, in case one has several kinds of output. Currently, the solution provided by xUnit works for me, thus, adding an |
This is absurd behaviour from one of the largest development toolkits there is. This is not an issue of whether a test framework should swallow logs, the issue is about the fact that 2/3 major platforms don't and one platform does. On my team we just discovered that our Mac developers see logs in the tests (e.g. stack traces) and our Windows developers don't (and have been working in a totally different way). This is not something that is up to personal preference / should be a setting / can be worked around, it is broken and needs to be fixed because it's not consistent.
Can we at least get some agreement here about whose backlog this should be on? Pointing fingers is just harming users and has been doing so now for 6 years. cc: @Evangelink |
@peabnuts123 For sure, lobbing insults is not going to get you results. |
@bradwilson What results? There have been no results in 6 years. |
@peabnuts123 I was on a long leave and I am just back. I will read all this thread and try to give some information/ask for plan about this. |
Thank you for making this point @peabnuts123, it's unbelievable that such a major framework should be broken in such fundamental way for so long, and on Windows of all platforms. I was mortified when I found out our Mac developers had been having a completely different experience with this all this time. |
Wow, on a leave for 6 years... And the issue didn't get assigned to anyone else... |
It would be great if this discrepancy could be resolved. I'm surprised it's been outstanding for so long. This is making it harder for me to debug issues during testing for libraries that I do not govern, and as such cannot modify their methods of outputting to the console; I can see their logs in Linux, but not Windows. |
We also want the Console.WriteLine to simply flow through the console. its unexpected behavior not to have this output and have the framework eat it somewhere. All we see is "Test passed" but we need to see the actual test log. |
I am on Windows, and when I first setup xunit a few days ago (using the Kind of weird how it changed. Unfortunately I cannot pinpoint what could have possibly affected it. Is there a way to make |
Hello. Is there any update on this egregious seven year old bug affecting users running on Windows, a platform I understand the project owner has some interest in? |
Console log debugging is a real pain now. It's not always possible to inject |
@pluma9 this should work without needing to pass in ioutputhelper https://github.com/SimonCropp/XunitContext/ |
it's amazing that after an hour of pulling my hair out as to why this wasn't working, I'm back to using linux on windows to debug a windows application. Microsoft will be Microsoft. |
From @jonsequitur on December 15, 2016 19:10
Steps to reproduce
Console.WriteLine
call in a test, .e.gGivenThatIWantToMigrateTestApps.ItMigratesRootProjectAndReferences
dotnet test --test-case-filter "FullyQualifiedName=Microsoft.DotNet.Migration.Tests.GivenThatIWantToMigrateTestApps.ItMigratesRootProjectAndR eferences"
Expected behavior
The string passed to Console.WriteLine appears in console output.
Actual behavior
Environment data
dotnet --info
output:.NET Command Line Tools (1.0.0-preview5-004253)
Product Information:
Version: 1.0.0-preview5-004253
Commit SHA-1 hash: 0caae96daf
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\dev\github\cli\artifacts\win10-x64\stage2\sdk\1.0.0-preview5-004253
Copied from original issue: dotnet/cli#5033
The text was updated successfully, but these errors were encountered: