Search code examples
loggingnunitnant

How can I add log messages to an NUnit test that will appear in a nant build execution?


With NUnit, if you add Debug.Print statements in your tests they appear in the test output. (At least they do in the ReSharper unit test window.)

When using a NAnt build file that executes the same tests, those Debug.Print statements do not appear.

How can I add messages to my unit tests that will appear both in the NUnit output and the build log output from NAnt?


Solution

  • Console.WriteLine() should be preserved (it is for my version of NUnit at least).

    That said, consider - each time you want to add some text output - how you could turn it into an assertion with a message. Your tests will get much better.