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
DefaultTimeout in .runsettings + TearDown method seems to break test output #4598
Comments
Thanks for the clear and minimal repro @patrykpiotrmarek |
A repro for this was uploaded by @patrykpiotrmarek for investigation in nunit/nunit.issues#3 |
Interesting, and fascinating. I can confirm this from within Visual Studio using the "Tests" output pane. |
Hm. Ok. This seems to manifest on net8 only. I can still see the output on net48 when consuming NUnit 4.0.0 or 4.1.0 |
I can't really explain why it happens, but this feels related to the changes in the This setting gets read in here: nunit/src/NUnitFramework/framework/Api/NUnitTestAssemblyRunner.cs Lines 312 to 313 in 331944e
Which I think then causes a nunit/src/NUnitFramework/framework/Internal/Execution/SimpleWorkItem.cs Lines 150 to 157 in 331944e
Adding // This works
[TestFixture, CancelAfter(60000)]
public class Tests
{
[Test]
public void Test1()
{
TestContext.WriteLine("line1");
Assert.That(1, Is.EqualTo(0));
}
[TearDown]
public void TearDown()
{
}
} |
@patrykpiotrmarek Sorry it took us a while to investigate. This means that at least as a workaround it should be possible to see the output on .NET 8 by applying the |
Note that |
Good point, thanks @manfred-brands ! I had forgotten to mention that. It's also worth mentioning that |
A bit of an update here as I have to pause my own investigation for now An early option I'd considered but had to rule out was passing the TextWriter around by simply adding a new parameter to I did manage to "fix" it in a branch here: https://github.com/stevenaw/nunit/tree/4598-timeout-context-output though I'm not particularly happy with the result. It meant extending and wrapping a An idea I haven't time to pursue yet is "snapshotting" the state of the TestResult at the time of the Timeout and applying it to the context here. It's possible there may be other options here too. |
@stevenaw the timeout refactor is working good for net462 and net8. For net6 this now throws a PlatformNotSupported exception as it never previously worked as intended. I hope to get the PR up this weekend. |
Fantastic, thanks @manfred-brands . |
NUnit v4.0.1 (regression after upgrade from 3.x)
I have simple test class with
TestContext.WriteLine
in test method andTearDown
method.and .runsettings file with
DefaultTimeout
settingWhen I run this code from dotnet test with
--settings
parameter, there is no output message other than assertion.Everything works fine after I remove
TearDown
method orDefaultTimeout
settingThe text was updated successfully, but these errors were encountered: