3

I am testing an F# project using NUnit. On the debug tab of project configuration I have set the debugger to use an external program which is nunit-console here and the working directory to the debug folder of my project. I prefer using nunit-console with the debugger since the GUI version doesn't hit the test file's breakpoints.

When I debug the test the console window appears and disappears and there is no chance to read the output. I have tried Console.Readline(), but it doesn't work because when I directly run the test from a terminal using nunit-console, it fails due to this command.

Is there a way to redirect the nunit-console output to the Visuals Studio's output window?

UPDATE: I could use Thread.Sleep() to delay the nunit-console.exe when I run the test from the console. But from Visual Studio it doesn't happen so I am pretty sure that nunit-console.exe fails to read the test file when the command is issued by Visual Studio. Still, it would be very nice to be able to read the console output, thus the redirection is still desirable.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
amirmonshi
  • 649
  • 5
  • 19

2 Answers2

1

Either use Tools->Options...->Debugging->General:"Redirect all Output Window text to Immediate Window" and then make sure that the "Immediate Window" is visible with Debug->Windows->Immediate.

Or use NUnit's "/wait" command line option.

wmeyer
  • 3,426
  • 1
  • 18
  • 26
  • The /wait option works greatly. However, I have another question that you might kindly answer? now that I can see the output of the nunit-console I can assure that the test is running but it does not hit the breakpoint. Do you know why? I am sorry if my questions are dumb I have only been working with .NET and F# for a short time. – amirmonshi Feb 24 '11 at 13:18
  • I am using TestDriven.NET now which fixed the problem with breakpoints. – amirmonshi Feb 24 '11 at 14:00
0

Unless I am missing something, you should be able to hit all your breakpoints with the GUI as well, set the startup project to nunit.exe and pass the name of your test DLL as a command line parameter. You will hit the breakpoints in Visual Studio, and your print statments will be in the GUI's output tab.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex
  • 2,342
  • 1
  • 18
  • 30