views:

630

answers:

2

Hi, I've just started using resharper and I found a very annoying thing about it. When debugging a unit test, I try to step-into (F11) a method, but visual studio complains that source code is not available. The problem is that resharper is wrapping method calls with its own classes. Of course I can put a braeakpoint further in my source, but this is very annoying. Do you know if there´s a solution for this? By the way, I'm using NUnit to write my tests

Thanks

Federico

A: 

What type of tests are you running - NUnit? MS Test? Something else?

I've never found it difficult to debug tests using R# - just put a breakpoint in your test and go. What method are you trying to step into? I've generally not tried to step into the NUnit methods themselves (assertions etc) but stepping into your own code should be okay.

If you can come up with a quick example, I'd be happy to try it myself.

Jon Skeet
I've edited my question. I'm using NUnit. I put a breakpoing in the first line of the test, and then I step into that method (my own class). I've tried TestDriven.NET and it works fine, so I dont think I am doing anything strange
fede
Are you sure the problem isn't that it's just trying to load the class, and R# may have some custom loading events or something similar? Again, if you could give a full example I'll try to reproduce it.
Jon Skeet
Oka, I've solved it doing the following: Tools | Options | Debugging | uncheck Step over properties and operators (Managed Only)
fede
+2  A: 

After some playing around I managed to recreate this on my setup (Xunit.net in resharper, visual studio 2008)... The steps I took to recreate this are:

  1. Set the dll that contains the tests as the startup project (I know you don't need to do this, was just trying to get it to fail)
  2. Put a breakpoint in the unit test
  3. Push F11 (the shortcut key for 'step into' in my configuration)
  4. This complains 'Cannot start test project 'RowanBeach.Crm.Domain.Test' because the project does not contain any tests.'
  5. Run the 'Debug Unit Tests' command from the Resharper menu (I have this bound to a key combination on my machine)
  6. This displays the 'No source code available...' message

Of course that's not how you should start unit tests from resharper! :) If that's what you were doing (or something similar), try this instead:

  1. Don't bother setting the dll as the startup project - it doesn't need to be
  2. build or rebuild the dll that contains the tests
  3. set the breakpoint
  4. Put the cursor somewhere in the source code for the unit test you want to debug to set it as the 'current context' unit test
  5. Run the 'Debug Unit Tests' command from the Resharper menu (You might want to bind this to a key combination if you haven't already)

Hopefully, that should work

Steve Willcock