What I am trying to achieve is quite simple but I am probably missing something. All I want is to INSTATNLY see my tests logging in the Console window, I have tried
Console.WriteLine(...)
I have tried
Trace.WriteLine(...)
I have tried
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
Trace.WriteLine(...)
This all show the output only AFTER the test has finished (and not in the Output console but as the "test output"), what I want is to see those logging as they happen. The way I am running the tests is using "Test-> Run-> All Tests" from the VS main menu.
The only way I can somewhat achieve what I want is by using
Debug.WriteLine(...)
But for this I have to run the tests in debug "Test -> Debug -> All Tests" and its kinda annoying...
Am I missing something?
In the main menu of VS, choose View > Output, then within the Output pane, pick "Tests".
Run tests in Test Explorer If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
A unit test provides a strict, written contract that the piece of code must satisfy. As a result, it affords several benefits. Unit testing finds problems early in the development cycle. This includes both bugs in the programmer's implementation and flaws or missing parts of the specification for the unit.
There is no way to achieve this except the one which you already know. MSTest adapter keeps caching the trace output and once test finishes, it emits it in the test output window.
This is a useful ask and I will pass this request to the mstest product owner in visual studio team.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With