Visual Studio FsUnit测试设置 - 异常NUnit.Engine.NUnitEngineException

问题描述 投票:2回答:3

我使用的是Visual Studio 2013,安装了FsUnit 2.2.0,它需要NUnit 3.2.1和FSharpCore 3.1。我创建了一个单独的测试项目,并在那里放了一个testfixture和test。我的平台是x64 Win 10.配置是'AnyCPU'和'Debug'。我已经尝试过x86和x64的测试设置。在尝试构建和创建测试时,我得到:

------ 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),那么基础项目的错误就会消失,但测试项目也会发生同样的事情。

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

visual-studio-2013 nunit fsunit
3个回答
2
投票

我在.NET Core 2.0NUnit 3.9Visual Studio 2017项目有同样的问题,测试没有出现在TestExplorer。坚持了很长一段时间。其他相关问题中提出的解决方案都没有奏效。

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

所以,步骤是

  1. 确保测试项目针对.NET Core
  2. 安装最新的NUnit NuGet(我用3.9)
  3. 安装相应的NUnitAdapter NuGet(我使用的是NUnit3Adapter)
  4. 安装Microsoft.NET.Test.Sdk NuGet

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


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


4
投票

您需要从解决方案中删除nunit并使用“NUnit3TestAdapter”再次安装它,版本3.0.10可以正常工作。

在添加/删除程序和解决方案中卸载任何NUnit软件。现在使用Nuget包管理器(工具> NuGet包管理器>管理NuGet包以获得解决方案......)删除解决方案中的任何NUnit并安装旧版本(例如3.0.1)。找到“NUnit3TestAdapter”并在3.0.10版中安装。


1
投票

NUnit 3.2.1中存在错误,其中TestEngine假定它无法运行需要在进程中执行32位的测试。该假设对于NUnit自己的跑步者始终有效,但不一定在某个其他程序启动该过程时有效。有关于此的问题。

© www.soinside.com 2019 - 2024. All rights reserved.