Console output from application is logged as warnings
See original GitHub issueSummary
When writing console output from the application under test, the output is displayed as a warning in the Visual Studio Test Explorer. This holds true both for the standard output stream (Console.Out.Write()) as well as for the standard error stream (Console.Error.Write()).
internal class Program
{
internal static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.Error.WriteLine("Hello, error stream!");
}
}
Steps to reproduce
- Create a .NET console application project (“MyApp”)
- Change the protection level of the
Mainmethod from implicitprivatetointernal Writeto the standard output and/or standard error stream from within theMainmethod- Create an NUnit test project (“MyApp.Tests”)
- Add a project reference from the test project to the application project
- Make internals of the application project visible to the test project by editing
MyApp.csproj:<ItemGroup> <InternalsVisibleTo Include="MyApp.Tests"/> </ItemGroup> - Add invocation of the
Mainmethod to the default test case:[Test] public void Test1() { Program.Main(new string[] { }); Assert.Pass(); } - Run the tests in Visual Studio’s Test Explorer
- Observe the reported warning(s) in the Test Explorer
Version information
- NUnit 3.13.3
- NUnit3TestAdapter 4.4.2
- Visual Studio Community 2022 (64-bit), version 17.5.0
- Target framework: .NET 6.0
Issue Analytics
- State:
- Created 4 months ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Warning in System.out when an error is logged in a custom ...
If an errors is logged, I would like to get a warning in the System.out with a notice to take a look at...
Read more >Log messages in the Console - Chrome Developers
Click the Log Warning button in the demo. Abandon Hope All Ye Who Enter gets logged to the Console. Messages formatted like this...
Read more >Log messages in the Console tool - Microsoft Edge
Console messages examples: log, info, error, and warn. The Console object has several levels of message-logging methods: console.log - Prints ...
Read more >console: warn() method - Web APIs | MDN
The console.warn() method outputs a warning message to the Web console.
Read more >Don't let ASP.NET Core Console Logging Slow your App down
NET Core 2.x Console logging is very, very slow when it is set to Information or worse Debug . The default ASP.NET Core...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I think the reason is historical. There was something many years ago that only error streams were displayed, so that started it. And in order not to break people who used that to get stuff into their CI logs, we kept it that way, but added the ConsoleOut. The default however, should have been changed, as you point out, so next breaking version I’ll get that done 😃
That was weird. I’ll check this out! Thanks for checking this with MSTest.