Visual Studio FsUnit 测试设置 - 异常 NUnit.Engine.NUnitEngineException [英] Visual Studio FsUnit test setup - Exception NUnit.Engine.NUnitEngineException

查看:54
本文介绍了Visual Studio FsUnit 测试设置 - 异常 NUnit.Engine.NUnitEngineException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Visual Studio 2013,安装了 FsUnit 2.2.0,它需要 NUnit 3.2.1 和 FSharpCore 3.1.我创建了一个单独的测试项目,并在其中放置了一个测试夹具和测试.我的平台是 x64 Win 10.配置用于AnyCPU"和调试".我已经尝试过 x86 和 x64 的测试设置.在尝试构建和创建测试时,我得到:

I am using Visual Studio 2013, installed FsUnit 2.2.0, which requires NUnit 3.2.1 and FSharpCore 3.1. I created a separate test project and put a testfixture and test in there. My platform is x64 Win 10. The config is for 'AnyCPU' and 'Debug'. I've tried test settings for x86 and x64. When trying to build and create tests, I get:

------ Discover test started ------
NUnit Adapter 3.2.0.0: Test discovery starting
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\Users\Dad\Documents\Visual Studio 2013\Projects\...
Cannot run tests in process - a 32 bit process is required.
NUnit Adapter 3.2.0.0: Test discovery complete
========== Discover test finished: 0 found (0:00:00.1230077) ==========

如果我将测试项目和目标项目的配置都更改为x86"(而不是 AnyCPU),那么基础项目的错误就会消失,但测试项目也会发生同样的情况.

If I change the config for both the test and target projects to 'x86' (instead of AnyCPU) then the error for the base project goes away, but the same thing happens for the test project.

从未发现任何测试,请帮助......非常感谢!

No tests are ever discovered, help please ... and many thanks!

推荐答案

我的 .NET Core 2.0 项目与 中的 NUnit 3.9 遇到了同样的问题Visual Studio 2017 和测试未显示在 TestExplorer 中.被这个问题困扰了很长一段时间.其他相关问题中建议的解决方案均无效.

I had the same problem with my .NET Core 2.0 project with NUnit 3.9 in Visual Studio 2017 and tests were not showing up in TestExplorer. Was stuck with this for quite some time. None of the solutions suggested in other related questions worked.

然后我从 this 链接中发现目标 .NET Standard 的类库不起作用.测试项目必须以 .NET Core 为目标.此外,Microsoft.NET.Test.Sdk NuGet 是必需的.

Then I figured out from this link that a class library with target .NET Standard does not work. The test project has to target .NET Core. Also, Microsoft.NET.Test.Sdk NuGet is required.

所以,步骤是

  1. 确保测试项目面向 .NET Core
  2. 安装最新的 NUnit NuGet(我用的是 3.9)
  3. 安装对应的NUnitAdapter NuGet(我用过NUnit3Adapter)
  4. 安装 Microsoft.NET.Test.Sdk NuGet
  1. Make sure that the test project targets .NET Core
  2. Install latest NUnit NuGet (I used 3.9)
  3. Install corresponding NUnitAdapter NuGet (I used NUnit3Adapter)
  4. Install Microsoft.NET.Test.Sdk NuGet

重新构建,您的测试将出现在 Visual Studio 的测试资源管理器中.

Re-build and your tests will appear in Test Explorer in Visual Studio.

注意:已将此答案添加到另一个 .NET Core 特定问题.也在此处添加,因为该解决方案在这种情况下也可能会有所帮助.

Note: Already added this answer to another .NET Core specific question. Adding here too, as the solution might be helpful in this scenario as well.

这篇关于Visual Studio FsUnit 测试设置 - 异常 NUnit.Engine.NUnitEngineException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆