如何在 Visual Studio 2015 中运行 UWP NUnit 测试? [英] How to run UWP NUnit tests in with Visual Studio 2015?
问题描述
这个问题专门针对运行用 C# 为 NUnit 编写的通用 Windows 平台 (UWP) 单元测试.
如何在 Visual Studio 中发现和运行这些测试?
我在网络上找不到关于这方面的权威文章,这真是令人惊讶.
我碰巧问到 xUnit 是否仍然是编写测试的唯一方法.Xamerin/UWP 的 NUnit Wiki
我目前的设置是
- Visual Studio 2015 社区
- Nunit 测试适配器 (3.2.0)
- Nunit 3 模板 (1.2)
我在跨平台部分添加了一个新项目(在撰写本文时已安装 NUnit 模板).我为 UWP 添加了一个模板.这是创建的 projects.json
,因此您可能只需编辑您的 xUnit,但这更容易
据我所知,这更像是一个测试运行器,而不是一个测试项目.看起来 xUnit 和 NUnit 都希望你创建一个包含所有测试的 PCL 项目,然后在这个 UI 项目中引用它并像这样运行你的测试.在撰写本文时,我想测试它是否进行了卷影复制,以便您可以在没有调试器的情况下运行并一遍又一遍地运行测试.我希望它可以,如果可以我会稍后报告.希望这有帮助
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
这篇关于如何在 Visual Studio 2015 中运行 UWP NUnit 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!