Exactly as what asked in "Writing to output window of Visual Studio?", however solving the remaining issue --
I assume there is no way to write to output if i start without debugging (ctrl-f5) right? – previous_developer Feb 27 '12
Debug.WriteLine() will only work when running in Debug. That means running it with F5 and not CTRL-F5. – kirk.burleson Jul 15 '13
However, it is not the case because:
Just ran a small app here, works fine for me. Perhaps there is a small glitch in your environment? – Bhargav Bhat Feb 27 '12
- Moreover,
I can see some Informational printed in Visual Studio output window during normal run:
[1/10/2018 11:56:25 AM Informational] ------ Run test started ------
[1/10/2018 11:56:26 AM Informational] NUnit Adapter 3.9.0.0: Test execution started
[1/10/2018 11:56:26 AM Informational] Running selected tests in ...\Demo.dll
[1/10/2018 11:56:26 AM Informational] NUnit3TestExecutor converted 14 of 14 NUnit test cases
[1/10/2018 11:56:45 AM Informational] NUnit Adapter 3.9.0.0: Test execution complete
[1/10/2018 11:56:45 AM Informational] ========== Run test finished: 1 run (0:00:19.3066647) ==========
For to run in debug mode, The NUnit debug output will look like:
[1/10/2018 2:56:55 PM Informational] ------ Run test started ------
[1/10/2018 2:56:56 PM Informational] NUnit Adapter 3.9.0.0: Test execution started
[1/10/2018 2:56:56 PM Informational] Debugging selected tests in ...\Demo.dll
[1/10/2018 2:56:57 PM Informational] NUnit3TestExecutor converted 14 of 14 NUnit test cases
[1/10/2018 3:03:38 PM Informational] NUnit Adapter 3.9.0.0: Test execution complete
[1/10/2018 3:03:38 PM Informational] ========== Run test finished: 1 run (0:06:43.6161412) ==========
I.e., regardless normal run or in debug mode, NUnit Adapter is able to write to the Visual Studio output window, the difference is only in the text "Running selected tests" or "Debugging selected tests"
So, here is the summary of debugging output cases during normal run, not in debug mode:
- For C# Console, both
Debug.WriteLine
andTrace.WriteLine
works fine. I've created and verified with this: https://pastebin.com/Du6ZbDV3 - However for Class/Form etc that don't have Console, neither
Debug.WriteLine
norTrace.WriteLine
work. Example: https://pastebin.com/b7P0bYEa. "It is pretty simple but still nothing – previous-developer Feb 27 '12". - In NUnit testing, which is C# Class lib, neither
Debug.WriteLine
norTrace.WriteLine
works. I've run mine several times and can confirm this. I'll not be posting my test code here because it is lengthy & needs lots of libs to work, moreover, it is caused by the same glitch as https://pastebin.com/b7P0bYEa.
So all in all, How to write to Visual Studio output window from class lib or win forms?