nunit3-vs-adapter
nunit3-vs-adapter copied to clipboard
Console.WriteLine statements in "OneTimeSetUp" and "OneTimeTearDown" is not captured
Given this test fixture:
[TestFixture]
public class TestClass
{
[OneTimeSetUp]
public void FixtureSetup ()
{
Console.WriteLine ("FixSetUp");
}
[SetUp]
public void SetUp ()
{
Console.WriteLine ("SetUp");
}
[TearDown]
public void TearDown ()
{
Console.WriteLine ("TearDown");
}
[OneTimeTearDown]
public void FixtureTearDown ()
{
Console.WriteLine ("FixTearDown");
}
[Test]
public void Test ()
{
Console.WriteLine ("Test");
}
}
It would be expected that Console.WriteLine ("FixSetUp");
and Console.WriteLine ("FixTearDown");
are correctly printed to test results window.
@GrimaceOfDespair commented on Tue Nov 15 2016
just fyi, this is my VS console output on these tests:
@CharliePoole commented on Tue Nov 15 2016
@GrimaceOfDespair Are you running vstest.console? That would be a completely different issue. None of these writes are displayed directly. They are events that each runner has to handle. This issue was about how the nunit console runner handles it. We probably need another for the nunit VS adapter.
@GrimaceOfDespair commented on Tue Nov 15 2016
I was under the impression, again wrongly, that the Standard Output was "just a capture" of the same stuff that came out of the console. I guess in theory it is, but in practice, there's a difference.
Apparently, I'm a bit confused as to which project I should be talking to whom, though that probably will most of the time be you :) You want me to file an issue with nunit3-vs-adapter?
@rprouse commented on Tue Nov 15 2016
@GrimaceOfDespair I will copy this issue across to the adapter project and edit it to reflect your issues.
@GrimaceOfDespair, your issue is now in the adapter repo. Feel free to subscribe to it.
That's even worse :
If you write a lambda using Console.WriteLine()
; and use it to setup objects during the OneTimeSetup
; Then when the lambda is invoked during the tests, the Console.WriteLine()
output is not captured.
That's only a funny implementation detail, but is it time consuming when you wonder why it won't output something.
@antibarbie Not sure what "That's even worse:" is referring to in the thread.
However, any Console.WriteLine()
during OneTimeSetUp
is captured and becomes part of the XML output of the test you are setting up. That would normally be the fixture, of course, not an individual test case. If you are using a runner that ignores fixture output, then you never see it. So, for example, you would not see it in using the VS adapter to run tests, while you would see it when running the nunit console.
Will this ever be fixed? In Visual Studio, MSTest simply displays the console output in ClassInitialize in the first test case. I am not sure if it is a feature or a bug but it is better than none in the imperfect world.
Any timeline for this issue. it has been over 5 year.
Any timeline for this issue. it has been over 5 year.
We accept PR fixes 😉