Debugging tests not working in VS2012

Dec 27, 2012 at 4:23 PM

Hi,

Debugging tests does not work for me in 2012. In an upgraded 2010 project, the test runs but never hits the breakpoint. In a newly created 2012 project, I get a warning first about not being able to find symbols. If I turn off "warn on no user code" then it runs exactly the same as the upgraded 2010 project. ie. it never hits the breakpoint.

Anything obvious I could be doing wrong here?

Thanks 

Dec 28, 2012 at 4:54 AM

Do you know how to check the solution's CONFIGURATION SETTINGS?

If so, check to make sure you are in DEBUG mode. Then, make sure you do a BUILD on your test project (which should then also do a build on your dependant projects).

Once that is done, try and run the test again.

When you run the test, make sure the cursor is INSIDE of the FACT you wish to debug (which calls other methods, etc).

Try that stuff and report back.

Dec 28, 2012 at 8:09 AM
Edited Dec 28, 2012 at 8:26 AM

Er, yes. It's a Debug build with a breakpoint within the fact. VS is reporting the test as run, but it's not hitting the breakpoint. I've tried building and rebuilding (didn't help), I checked that the PDBs were present (they are), I gave the test a display name to make sure VS correctly picks it up (it does), I tried turning off just my code (didn't help).

FWIW, here's my fact:

 

        [Fact(DisplayName = "My Test")]
        public void test()
        {
            Console.WriteLine("Test");
        }

My breakpoint is on the Console.WriteLine call.

Dec 28, 2012 at 8:27 AM

I've just noticed that debugging doesn't work at all in my VS2012 - not just xUnit. Even a console app is successfully running under the debugger, but breakpoints are not hit. Very strange...

Dec 28, 2012 at 8:34 AM

OK, found the problem. My VS options seemed to be a bit screwy, despite the fact that I only just installed it yesterday. The Debugging/Symbols options had "Only specified modules" selected instead of "All modules, unless excluded". Even though symbol server is off, it still seems to be honoring this setting, so symbols just weren't being loaded for my DLL. Having changed that setting, both the console and xUnit debugging scenarios work now.

Thanks.