Reported by alex Oct 05, 2017 at 04:54 AM visual studio for mac unit-test. I have a.net Core 2.0 solution. I have MSTest based unit tests. I can 'run' the unit tests in VS for mac. How do I run NUnit in debug mode from Visual Studio? Ask Question. Up vote 113 down vote favorite. When I need to debug my NUnit tests, I simply attach to the NUnit GUI application nunit-agent.exe using 'Debug|Attach to Process' and run the tests from the GUI. Any breakpoints in my tests (or the code they're testing) are hit. 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'm running Visual Studio 2017 Mac version 7.3 (build 764). The tests run from the Unit Test pad just fine (green circle and console output happens if I add output), but the debugger doesn't break when I set a breakpoint or expicitly throw an exception in the test.
If you're using Visual Studio for Mac the NUnit templates extension can't be used. This guide assumes that you have a solution with either a PCL or a Shared project and a number of platform specific projects. It doesn't matter if you're using Xamarin.Forms or Xamarin.iOS/Xamarin.Android directly. Your solution might look something like this:
Run Nunit Tests Visual StudioShared Test ProjectVisual Studio For Mac Os
First, create a new PCL that holds your shared testing code, so the test code doesn't end up in production builds. Right Click on the Project Solution and Add a new project using the Cross-Platform Shared Library Template. Use Project.Tests as a name. Design studio for mac. Afterwards, your solution should look like this: Code composer studio 5.
Edit the references of the newly created test project so that it contains a reference to the standard PCL. Afterwards, add a NuGet dependency on NUnit by right-clicking on Project.Tests and selection Add -> Add NuGet Package. Note: https://krpowerful.weebly.com/blog/free-studio-5-for-mac. Ensure you reference the same version of NUnit as the version of nunit.xamarin you are using. e.g. If you are using nunit.xamarin 3.0.1, add the v3.0.1 NUnit NuGet package. Afterwards, your test project is ready.
![]() Platform runners
In order to run the tests it's necessary to create a project for each platform you'd like to support (iOS, Android and so on). Do so using the standard Xamarin templates for new platform projects. Dependency injection c# visual studio for mac. It's probably sensible to use a naming scheme like Project.Tests.iOS for the individual test projects do keep your solution structured.
The NUnit.Xamarin runners are built using Xamarin.Forms, so you need to add NUnit, NUnit.Xamarin and Xamarin.Forms as NuGet dependencies to the newly created projects. It's also necessary to add a reference to the shared test project containing the tests.
Visual Studio For Mac Os X
If you've followed the steps above, you can now replace the AppDelegate.cs or MainActivity.cs with the code shown below. Since your tests are not in the same assembly as the runner it's a good idea to create a canary test class in the Shared Test Projects that you can use to reference the test assembly explicitly. In the example below, the name of this class is MyTest.cs.
![]() Android
MainActivity.cs
iOS
AppDelegate.cs
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |