2

I have the following test:

    [Test]
    public void RetrieveWrongURL()
    {
        Debug.WriteLine("In RetrieveWrongURL");
        Console.WriteLine("In RetrieveWrongURL");
        Assert.Throws<IncorrectUrlSuppliedException>(() => mRetriever.doSomething("https://someWrong.url"));
    }

When I am running the test, in the Output window I am getting:

[05/01/2018 10:23:40 Informational] ------ Run test started ------
[05/01/2018 10:23:41 Informational] NUnit Adapter 3.9.0.0: Test execution started
[05/01/2018 10:23:41 Informational] Running selected tests in Z:\path\to\my\dll\MyDll.dll
[05/01/2018 10:23:41 Informational] NUnit3TestExecutor converted 3 of 3 NUnit test cases
[05/01/2018 10:23:42 Informational] NUnit Adapter 3.9.0.0: Test execution complete
[05/01/2018 10:23:42 Informational] ========== Run test finished: 1 run (0:00:02.0995689) ==========

How can I write anything to the output window?

bsky
  • 19,326
  • 49
  • 155
  • 270
  • Possible duplicate of [replace Console.WriteLine in NUnit?](https://stackoverflow.com/questions/6833558/replace-console-writeline-in-nunit) – BWA Jan 05 '18 at 10:30

2 Answers2

2

Try the following:

NUnit.Framework.TestContext.WriteLine("text");

NOTE: The NUnit console displays text output from tests at the end of each test. A summary report is produced at the end of the test run. This has been the case since NUnit 3.0. Before that, output was sent to the console immediately as it was produced.

Enter image description here

Enter image description here

Alex
  • 14,973
  • 13
  • 59
  • 94
Pokis
  • 35
  • 7
0

Use this

System.Diagnostics.Debug.WriteLine("something");
Ray Krungkaew
  • 6,652
  • 1
  • 17
  • 28