简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM