Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run UWP NUnit tests in with Visual Studio 2015?

This question is specifically about running Universal Windows Platform (UWP) unit tests written in C# for NUnit.

How can I discover and run these tests in Visual Studio?

I could find no definitive articles on this on the web, which is really surprising.

like image 715
bright Avatar asked Oct 30 '22 17:10

bright


1 Answers

I happened upon this asking if xUnit was still the only way to write tests. NUnit Wiki for Xamerin / UWP

My current setup is

  • Visual Studio 2015 Community
  • Nunit Test Adapter (3.2.0)
  • Nunit 3 Templates (1.2)

I added a new project in the Cross Platform section (where NUnit templates are installed as of this writing). I added a template for UWP. This is the projects.json that is created so you can probably just edit your xUnit one, but this is easier

{
  "dependencies": {
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
    "NUnit": "3.0.1",
    "nunit.xamarin": "3.0.1",
    "Xamarin.Forms": "2.0.0.6490"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

From what i can tell this is more of a test runner than a test project. Looks like both xUnit and NUnit both want you to create a PCL project with all your tests then reference it in this UI project and run your tests like that. As of this writing I want to test if it does a shadow copy so you can run without a debugger and run your tests over and over again. I hope it can, i'll report back later if it can. Hope this helps

like image 62
Robert Snyder Avatar answered Nov 15 '22 04:11

Robert Snyder