Nunit not hitting breakpoints in test project class library (VS2012)

Viewed 5652

I have a console application and I added a class library solution to the project to hold all my unit tests.

All is working fine apart from the fact that breakpoints do not get hit when I run my tests.

If I run the whole application, breakpoints on the console app get hit fine.

If I run the tests, breakpoints in the test classes and the console app are completely ignored.

I saw another post saying to go to debug > start new instance, but as it is a class library I cannot do this. Should I have test classes in a different project type?

I am using Nunit, VS2012 and the NUnit runners.

I have a couple of tests failing and I cant figure out why, I really need to be able to step through the code.

Any help is greatly appreciated.

4 Answers

For anyone else having this issue: check if you are building in Release mode.

I had this problem with NUnit 3.7.0, and dotnet core 1.0, and VS 2017. It turned out that I was building in Release mode. Building in Debug mode fixed the issue.

In my case a line of code seemed to execute a never-ending loop, which made it impossible to reach the breakpoint.

Solution: Put a breakpoint in the beginning of the debug method in order to check for this error!

Related