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

可紊 提交于 2019-12-23 10:57:09

问题


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:


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



来源:https://stackoverflow.com/questions/33246626/how-to-run-uwp-nunit-tests-in-with-visual-studio-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!