nunit-console
nunit-console copied to clipboard
Nunit TestContext.Out.WriteLine writes text to console ouput with trace=off
Run Settings RunAsX86: True DisposeRunners: True DefaultTimeout: 1800000 InternalTraceLevel: Off WorkDirectory: .\TestOutput ImageRuntimeVersion: 4.0.30319 ImageTargetFrameworkName: .NETFramework,Version=v4.6.1 ImageRequiresX86: False ImageRequiresDefaultAppDomainAssemblyResolver: False TargetRuntimeFramework: net-4.6.1 NumberOfTestWorkers: 2
- Method of installation = Nuget.org
- Version of the NUnit Engine/Console = 3.16.1
- All versions of the NUnit Framework in use = 3.13.3
I'm not sure if this is a bug or an intended change, but in previous versions of NUnit Console I don't remember seeing the TestContext.Out stream being written to stdout. I have trace turned off, so I would only expect TestContext.Progress to be written to stdout. Was this behavior changed or is there some option that I am missing on the command-line to only have TestContext.Progress written to stdout?
It's not a change - at least not since NUnit 3.0.
The --trace option controls the InternalTrace setting, which is used by NUnit itself (framework, engine and console runner) to log it's own internal operation. It has no effect at all on the output you create from your test.
Output sent to TextContext.Out or TextContext.Progress becomes an event, which may be handled differently by each runner. In the case of the NUnit-Console runner, they are both displayed on the console. However, there is a slight difference in how they are displayed. That is, the Progress stream displays immediately while the Out stream becomes part of the test result and so it's only displayed upon completion of each individual test.
Charlie, your explanation makes sense, because that is what I seem to be seeing now (although I thought that didn't occur on the previous versions of the console runner that I used, but I could be mistaken). Is there any way to write text to to the NUnit Results XML without that being echoed to stdout at the end of each test? I would like to reduce the verbosity of the console output while still writing to the results file if that is possible.
You can experiment with use of the --out option, which sends output from a test to a file. NUnit's own text output, like the test summary, should still appear. IIRC there is an unimplemented feature request to give allow more granular control than that.
You can experiment with use of the
--outoption, which sends output from a test to a file. NUnit's own text output, like the test summary, should still appear. IIRC there is an unimplemented feature request to give allow more granular control than that.
Tried --out, but it didn't quite work the way I wanted. It routed Progress output to the file as well. I still want TestContext.Progress output to go to the console, but not stuff that was written to TestContext.Out.
See #938