2

I've placed a breakpoint here and am trying to debug the following code snippet:

Enter image description here

After clicking here and selecting debug, I am presented with a failed test:

Enter image description here

Enter image description here

What am I doing wrong? Why is it suddenly that I cannot debug my tests?

I'm referencing the following libraries:

using System;
using System.IO;
using System.Reflection;
using System.Text;
using MassTransit;
using MassTransit.Context;
using MassTransit.Serialization;
using NUnit.Framework;

I don't know if it matters, but I do have ReSharper:

Enter image description here

I also have NUnit installed, and although I do see it in extensions and I am able to reference it, I do not see it in my menus:

Enter image description here

Enter image description here

Also, as you can see I have the ability to set breakpoints:

Enter image description here

Why can I not debug my unit tests?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062

2 Answers2

5

I found the answer here.

I discovered that I wasn't outputting my debug information in my build. Right click on the project, go to 'properties', and select the 'build' tab. On the bottom of the page there's an 'Advanced...' button that will display your setting for your output debug information. Set that to 'full' and the error should go away.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
2

You are attempting to debug NUnit 3 unit tests in ReSharper. Only the most recent versions of ReSharper support NUnit 3. To be sure it is not a runner issue, try using the NUnit 3 test adapter that you installed.

To use the NUnit 3 Test Adapter, click on the main menu TestWindows → *Test Explorer. This will bring up the Visual Studio test explorer window.

Visual Studio Test Explorer Window

From here, you can right click and debug a test.

Debug Test

If your test fails before hitting your breakpoint, it is likely because it is failing earlier, for example in the test setup or in the OneTimeSetup. Click on your failed test in the Test Explorer window, and then look at the bottom of the window. You will see the failure and the stack trace. You can click on the stack trace to go to exactly where it failed in your code and put a breakpoint there.

Failed Test - Stack Trace

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rob Prouse
  • 22,161
  • 4
  • 69
  • 89