I'm not sure what I did, but all of a sudden, my Visual Studio 2012 will not debug any tests.
If I select a test from the Test Explorer and tell it to run, it simply outputs this in the Test Output window:
> ------ Discover test started ------
> ========== Discover test finished: 29 found (0:00:01.3371755) ==========
> ------ Run test started ------ Process with an Id of -1 is not running.
> ========== Run test finished: 0 run (0:00:01.4711861) ==========
what the heck does that mean?! After doing this a few times, the error changed to:
The Operation was Cancelled
which I sure didn't do.
It's doing this on every test in the list.
however, I can RUN the tests no problem, and they pass... but I cannot debug the tests.
What might I have done? I did not actively go into any settings and change anything, perhaps a stray click somewhere, but where?
Have regularly the same issue with Visual Studio 2012.
Solution : close the current solution and reopen it.
In my case closing and reopening VS was not necessary.
I was having similar issue in VS2015. Only one unit test could not be debugged in my case. Debugger would initialize a test, but would not debug test itself, nicely exiting. The problem was in Resharper importing Newtonsoft.Json library without enabling NuGet package for the project. (I used Alt+Enter to automatically import the library)
Solution was to install Newtonsoft.Json NuGet package for test project.
I encountered this today. I tried closing the solution but it didn't work. My mistake I set my solution to Release Mode instead of Debug Mode. I set it to Debug then it worked as expected.
I'm using VS 2015 professional.
Ensure your test project is part of the projects to build.
I was getting the same output after upgrading a test project from VS 2010 to VS 2012 Ultimate Update 3. The message was displayed in Test Output window after using MSTest command to Debug Selected Tests.
I tried to debug tests using Resharper 8 Unit Test Session window. The message in the result window was "Test wasn't run".
The solution that helped me was to modify the test project settings to enable native code debugging as instructed at this link: Uncaught exception thrown by method called through reflection
In case the link does not work:
Thanks to GalDude33 for posting the solution.
Hitting "Run tests" will not trigger the brakepoints.
To debug your code and stop at a breakpoint in a test:
Right-click > Debug Tests
or
"Test" tab > Debug > All tests