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?
Please follow below steps. It worked for me
Steps.
1.Close your visual studio instances
2.Clean you temp files and prefetch files.
3.delete the files in project bin folder.
4.Restart the applications.
For me the following worked:
As of Visual Studio 2017 (15.8), this can happen when the Live Unit Testing feature is active. There's no clear message in the output; it just starts and stops without debugging. The solution is stopping the live testing so then you can debug the test normally.
In my case, my symbols weren't loaded.
I had to go to Tools -> Options -> Debugging -> and select "Load all modules, unless excluded" for breakpoints to get hit.
app.config problem references can unwittingly cause the debugger not to attach and breakpoints not to be hit when debugging test projects. This file may have been updated by packages or has gone out of date.
Solution: I generally copy then remove all dependencies under the runtime tag from the test project's app.config. Debugging usuually starts working after this but some references may need to be added back if assemblies can't be found.
None of the proposed solutions worked for me. What worked for me is changing the unit test project and all dependent projects' platform target to Any CPU instead of x64 which is some kind of a workaround not a real fix !!
EDIT
The target platform for a unit test project could be changed from test settings not from the project's properties. Refer to this answer for more.