You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Standard output from a failing OneTimeSetUp or OneTimeTearDown is never shown #1558
When a OneTimeSetUp or OneTimeTearDown fails, standard output written in it (Console.WriteLine, TestContext.Out) never reaches the console, whatever ShowStdout or ConsoleOut is set to. That output is often exactly what explains the failure.
dotnet test shows the Boom failure, but not STDOUT-FROM-ONETIMESETUP.
The cause: NUnit sends only TestContext.Progress and error output as live test-output events. Standard output is kept in the result, and for a suite that is the <output> element of the test-suite event. NUnitEventListener.TestFinished reads <output> for test cases, but NUnitEventListener.SuiteFinished never reads it. SuiteFinished only sends the buffered Progress and Error output (added in #1554), so standard output from a fixture's setup or teardown is dropped. There is no test result to attach it to either, so it doesn't show up in the logger's failure report.
Fix: in SuiteFinished, after the buffered output, send resultNode.Output as a Warning when the suite failed in SetUp or TearDown (the method already returns early otherwise) and ShowStdout is not None. It is sent as a Warning, like the buffered output, so dotnet test shows it without a detailed logger. Passing suites send nothing, so agent mode stays quiet.
ShowStdout
Standard output of a failing OneTimeSetUp sent
All
Yes
Failed
Yes
None
No
The docs for ShowStdout (nunit/docs#1324) describe the current behavior and need a one-line update when this is fixed.
Activity
Send standard output of a failing OneTimeSetUp or OneTimeTearDown