Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 470
Guerrilla Avatar asked Dec 18 '13 07:12

Guerrilla


People also ask

Why are my breakpoints not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.

How do I Debug a NUnit test case?

Setting up VS.NET to debug your unit tests is very simple; just follow these steps: Right-click on the NUnit test project (MusicTest, in my case) and select Properties. Select Debugging under the Configuration Properties group. Enter nunit-gui.exe in the Start external program.

How do I enable breakpoints in Visual Studio?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.


1 Answers

Instead of running your tests, try debugging your tests

enter image description here

like image 99
Leo Avatar answered Oct 06 '22 05:10

Leo