本文介绍了Visual Studio 2012 中的 Windows 8 应用程序 - NUnit 测试适配器可以看到单元测试但不运行它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 8 Store 应用程序,其中包含两个解决方案中的项目 - 一个专用于测试的项目.我添加了 NUnit 和 NUnit 测试适配器 (.

您遇到的问题似乎是针对 NUnit 测试适配器的标准 .NET 库发生的,但上述 NUnitTestAdapterWithFramework 必须解决了这些问题.请参阅Q &NUnitTestExtension 的一部分

但不幸的是,这似乎仍然是一个尚未针对 Win8 Store App 类型单元测试修复的问题.很确定 xUnit.NET 也不兼容但与不同的 .NET 目标类型(即 WinRT)

那么有哪些选择呢?一种.对于您的组,您可以将它们更改为使用 MSTest 框架.结果 - 问题解决没有问题.

B.解决方法链接项目".结果 - 不能*保证**,但这也应该有效.

带有选项b"

在你提到的评论中.

但我仍然不确定它的作用或如何实现链接项目',你有更多关于这个的信息吗?另外,由于这是对于集体大学项目,我希望我不必强迫解决方法太多

仔细想想,这并不是真正的辛苦工作.这很简单,我相信您的团队能够轻松应用此解决方法.

请按照以下步骤操作.

  1. 在您的解决方案中创建一个单独的类库(您可以面向 .NET Framework 4).

  2. 然后像往常一样添加 NUnit 程序集和 NUnit 测试适配器.

  3. 右键单击此项目并选择添加",然后选择现有项目"

  4. 选择 Win8 Store Unit Test 项目并找到要添加的 Unit Test 文件.添加文件时,请确保选择添加为链接"按钮.请参阅下文.

  5. 现在重建解决方案,关闭并重新打开 UnitTest 资源管理器,您应该能够运行这些测试.

*我说的原因不能保证.我还没有真正针对 Win8 App 编写单元测试.因此,如果您的 SUT(被测系统)需要特殊配置,则可能会导致问题.但我不确定.

最后创建链接文件并不难,如果一切正常,您可以继续这样做,直到 NUnit 支持 Win8 单元测试.或者,另一种选择是尽可能将所有单元测试更改为使用 MSTest 框架.

I have a Windows 8 Store App with two projects within the solution - one project exclusively for tests. I have added NUnit and NUnit Test Adapter (https://www.nuget.org/packages/NUnitTestAdapter/1.0.0) for this through nuget.

My tests are detected - but I cannot run or debug them. Looking at the test output window, I get the following error:

Could not find test executor with URI 'executor://nunittestexecutor/'. Make sure that the test executor is installed and supports .net runtime version 4.0.30319.34003.

I am not using resharper and I am using Visual Studio Professional 2012 Update 3 on Windows 8.1. References for the test project are as follows:

解决方案

Based on my comments above, below is a workaround. Unfortunately at this stage, Windows 8.1 store Unit Test project types, using NUnit extension wouldn't work due to the different .NET targets. I tried with different Test Unit Adapters including an NUnitTestAdapterWithFramework.

It seems that the issue you haveing was occurring with standard .NET libraries targeting NUnit test adapter but the above NUnitTestAdapterWithFramework must have fixed those issue. See the Q & A section of the NUnitTestExtension

But unfortunatly it seems that this still of an issue that hasn't been fixed for Win8 Store App type Unit Testing. Pretty sure xUnit.NET also not compatible yet with different .NET target types (i,e WinRT)

So what are the options? a. For your group, you can change them to use MSTest framework. Outcome - Problem Solved no issues.

b. Workaround "linked project". Outcome - Can't *guarantee** but this should also work.

With option 'b'

In your comment you mentioned.

When you think about it, it is not really hard work around. It is simple and I'm sure your group would be able to apply this workaround easily.

Please follow the below steps.

  1. Create a separate class library in your solution (you can target .NET framework 4).

  2. Then add NUnit assemblies and the NUnit test adapter as usual.

  3. Right click on this project and select 'Add' then 'Existing Item'

  4. Select the Win8 Store Unit Test project and locate the Unit Test file you want to add. When you add the file, make sure you select 'Add As a Link' button. Please see below.

  5. Now rebuild the solution, close and re-open the UnitTest explorer and you should be able to run those tests.

*The reason I said can't guaranteed. I haven't really written Unit tests against Win8 App. So if your SUT (System Under Test) require special configuration it might cause issues. But I'm not sure.

Finally creating a link files are not that hard if everything works you can continue to do this until NUnit has the support for Win8 Unit Testing. Or the other option is simply change all your Unit Tests to use MSTest framework if possible.

这篇关于Visual Studio 2012 中的 Windows 8 应用程序 - NUnit 测试适配器可以看到单元测试但不运行它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:38