5
votes

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.

1
Did you check this post : thewindev.net/testing-windows-10-apps and this one too : xunit.github.io/docs/getting-started-uwp.html The second one is about xUnit but the idea remains the same, I think?Kevin Avignon
Quick question :why extrapolating from x Unit would not be good enough?Kevin Avignon
Things have evolved a bit since the blog article linked by @KevinAvignon, and the EAP version of Resharper now supports NUnit 3.0 Beta 4 (twitter.com/resharper/status/653667610287058945). Worth a try.Kevin Gosse
@kookiz so the OP would just need to write a basic nunit test and use the test runner of R9?Kevin Avignon

1 Answers

2
votes

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