简体   繁体   中英

How to launch Console from inside a NUnit test

I am running a NUnit testing. I need to launch Console to write test to it. When I write in my [Test]

Console.Write("test");

It doesn't work. I know we are not suppose to be running console or have human interaction. But I have situation where I need display message on Console. How can I do that?

If you are using the ReSharper test runner, if you need to see what is displayed on the console, the Console output should be displayed. To do that, click the "Show Output" button in the test runner toolbar:

在此处输入图片说明

Then, you will be able to see the output like this:

在此处输入图片说明

Or, if you use the NUnit GUI runner, there is a "Text output" tab which should show you what you need.

Or, of course, you could use Debug.WriteLine instead to output to VS's "output" box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM