When using Visual Studio 2008 and debugging my unit tests... sometimes the debugger works fine. However very often after modifying some code then clicking \"Debug Unit Test\
Make sure you are debugging the correct test!
I have some tests with very similar names except for the last word in the test name. I had the break point set in the first test and was using Visual Studios "Test Explorer" window to "Debug Selected Tests" on the second test, which didn't have a breakpoint set.
Test names
PublishAsync_Valid_Acked
PublishAsync_Valid_Nacked
I just had a problem hitting breakpoints in VS2015.
I am always using the solution configuration called Debug but for some reason my solution was set to build the Release version.
Switching from Release to Debug in the dropdown at the top of Visual Studio fixed my problem.
Another workaround: Force the debugger to be launched from within your unit test:
System.Diagnostics.Debugger.Launch();
One problem that I stumbled upon when trying to debug a test method was that it was private. Simply changing the method from private
to public
fixed my problem.
I don't know why this is a problem, but it probably has something to do with the implementation of the [Test]
attribute of NUnit.
If you have [HostType("ASP.NET")]
, remove it and Test -> Debug -> Run your tests again
Ensure [TestMethod] attribute is present for the method, [TestClass] is present for class.