Replace Console.WriteLine in NUnit

前端 未结 5 1899
野趣味
野趣味 2020-12-14 14:56

I haven\'t done much with NUnit before, but I just wanted to dump some text to a window in a console type fashion.

e.g. Console.WriteLine("... some infor         


        
相关标签:
5条回答
  • 2020-12-14 15:26

    In Visual Studio 2017, in the Test Explorer window, there is a link, Output, in the lower Test pane. This brings up anything written to the console during that unit test.

    0 讨论(0)
  • 2020-12-14 15:32

    You can see the console output. You just have to select the "Text Output" tab in the NUnit GUI runner.

    Enter image description here

    If you are using the ReSharper test runner, the console output should be displayed. Ensure that the test runner output window is displayed by clicking the "Show Output" button in the test runner tool bar:

    Enter image description here

    You should then get something as follows:

    Enter image description here

    0 讨论(0)
  • 2020-12-14 15:32

    Try using System.Diagnostics.Debug.WriteLine instead.

    0 讨论(0)
  • 2020-12-14 15:39

    Use the Test-Output view.

    Steps:

    1. Open Test Explorer
    2. Select any particular test
    3. Run it if it has never been run.
    4. Click on the output link on the test results pane.

    There is isn't any need to replace Console.WriteLine with anything as this view logs messages from:

    Console.WriteLine

    Trace.WriteLine

    Debug.WriteLine

    TestExplorer.Out.WriteLine

    0 讨论(0)
  • 2020-12-14 15:42

    In NUnit v3, you can also write to the test results output for debugging with

    TestContext.Out.WriteLine("Message to write to log");
    
    0 讨论(0)
提交回复
热议问题