ValYouW
ValYouW

Reputation: 749

Output of Unit Tests running in VisualStudio

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?

Upvotes: 14

Views: 3466

Answers (1)

Aseem Bansal
Aseem Bansal

Reputation: 799

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.

Upvotes: 2

Related Questions