Windows 8 App in Visual Studio 2012 - NUnit Test Adapter sees unit tests but does not run them

可紊 提交于 2019-12-11 06:01:18

问题


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:


回答1:


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.

but I'm still not sure what it does or how to implement a 'linked project', do you have any more information on this? Also, as this is for a group university project, I was hoping i wouldn't have to force too many workarounds

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.



来源:https://stackoverflow.com/questions/19871222/windows-8-app-in-visual-studio-2012-nunit-test-adapter-sees-unit-tests-but-doe

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