sircodesalot
sircodesalot

Reputation: 11439

Is there a way to activate the console while unit testing?

Pretty straightforward: I want to have the console display while I'm unit testing. Is there a way to turn this on directly, or do I have to use AllocConsole?

Upvotes: 0

Views: 182

Answers (2)

Jason Evans
Jason Evans

Reputation: 29186

In your tests you can still call Console.WriteLine which will output content to the console. The end result of doing that is, all that content will appear in the test results window (MSTest) or, for example, the Resharper unit test runner.

In order to get real-time output, via the console window, you may have to experiment with, maybe, using the console test runner of your chosen testing framework. For example, if you're using NUnit then try using the NUnit console test runner and see what happens. The crux of it is that, out of the box, there is no Visual Studio support to do what you want (I believe this is the case).

Upvotes: 1

BartoszKP
BartoszKP

Reputation: 35891

My only guess is to change the project type from class library to an executable application. Probably you still could run the tests, because all the test classes will be still present in the assembly and the console subsystem (or something) will be additionally present.

Upvotes: 1

Related Questions