Visual Studio For Mac Debug Nunit Test

Active2 months ago

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?

Community
Running nunit in visual studioBill MartinBill Martin
3,1068 gold badges45 silver badges83 bronze badges

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 Koritnik
79.4k43 gold badges247 silver badges369 bronze badges

There 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:

JahmicJahmic
6,9887 gold badges47 silver badges60 bronze badges

The 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 B
91.3k18 gold badges123 silver badges168 bronze badges

I 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)

rla4rla4

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.

k3bk3b
11.7k5 gold badges42 silver badges73 bronze badges

Visual 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.

Philip John
2,2884 gold badges27 silver badges47 bronze badges
Parmeshwar KaraleParmeshwar Karale

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.

cSharmacSharma
Visual studio for mac

Try changing the test to x64. From the menu do

Test ->Test Settings ->Default Processor Architecture ->x64.

ΩmegaManΩmegaMan
17.4k5 gold badges51 silver badges69 bronze badges

i think u cant debug with Visual studio. better u install TestDriven.NET.

then

X Code

  1. Put the BreakPoint on the test method
  2. Right click on the testmethod.
  3. select TestWith->Debugger

Visual Studio For Mac Os X

User_18User_18

Running Nunit In Visual Studio

Not the answer you're looking for? Browse other questions tagged visual-studio-2010visual-studiounit-testingnunit or ask your own question.