Trying to debug an NUnit test in VS2010 and is not stopping on the breakpoint. It was working the last time I tried need to debug the test (maybe 1 yr ago) but now it doesn't work.
Debugging unit tests.; 4 minutes to read Contributors. In this article. One of the most significant benefits to unit testing inside Visual Studio is the ability to debug your code during a test, and to debug the tests themselves. This is a long overdue question but I haven't seen the solution to debug NUnit tests directly within Visual Studio. This is quite easily possible and without any third party tools.
I've tried the following:
The easiest way to get started is to install the NUnit Templates extension for Visual Studio.It will add project templates for the various Xamarin platforms. For more general information, see Testing Xamarin Projects using NUnit 3. Getting started.
I've tried attaching, rechecking my installation, updated the config file so it's using the 4.0 runtime, still doesn't hit the breakpoint.
What am I missing?
9 Answers
This is a long overdue question but I haven't seen the solution to debug NUnit tests directly within Visual Studio. This is quite easily possible and without any third party tools. All you have to do is configure your test project (which is just a plain old Class library project) so it will start NUnit test runner whenever you hit F5 or Ctrl-F5 (just run, no debugging).
Particularly you will have to configure your project properties to start an external program:
Step by step configuration is very well described in this blog post. It advises you to use NuGet to obtain NUnit test runner and configure project to execute the runner when you try running your library project. As simple as that. Using no specific tools which are usually not free.
Robert KoritnikRobert KoritnikThere are multiple reasons why this may happen. If your application's target framework is different from NUnit's, then you won't be able to debug, because the tests are actually being run by nunit-agent.exe.
For me, my application was using 4.5, but NUnit's was using 3.5. (You can find this from one of the NUnit GUI applications -> Help -> About)
To fix this, change the nunit.exe.config file to include the following, inside the configuration section:
JahmicJahmicThe other day I failed to hit a breakpoint in my NUnit debugging. It took me a while to realize that someone had copy/pasted the test into a different file and I was running a different test than the one that the breakpoint was in.
Amy BAmy BI recently had a similar problem. Changing the project's platform to AnyCPU solved it for me. Also worth checking:
1) Check NUnit's latest version (I was using 2.5.7, updated to 2.6.2)2) The Target Framework for your test project. I was using .NET 4.0 (you can find it under Properties -> Application, on VS2010)
At least up to vs2010 the debugger can only debug 32 bit apps but not 64 bit apps.
With vs2010 I am using a 32bit nunit.exe version and use 'attach to debugger'. This workes well for me.
k3bk3bVisual Studio For Mac
You can debug nunit tests in VS studio community version only. For this you need to install Nunit3testAdpter
. You can add this in Tools -> Extension and updates. or from Nuget packages.
Please upgrade NUnit Test Extension and close the Visual studio so Visx (probably spell) will run and update NUnit tool.After this you can open your project and run NUnit test project. It will run. I tested accurately.
Try changing the test to x64. From the menu do
Test
->Test Settings
->Default Processor Architecture
->x64
.
i think u cant debug with Visual studio. better u install TestDriven.NET.
then
X Code
- Put the BreakPoint on the test method
- Right click on the testmethod.
- select TestWith->Debugger