NUnit 无法加载 DLL [英] NUnit failed to load DLL

查看:48
本文介绍了NUnit 无法加载 DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 Visual Studio 中运行单元测试时收到以下错误消息:

I am getting the following error message when trying to run unit tests in Visual Studio:

NUnit failed to load w:\Repos\trading.tools\Trading.Tools.Test\bin\x64\Debug\Trading.Tools.Test.dll

我正在使用

  • Visual Studio 社区 2013
  • NUnit 适配器 3.4.0.0
  • NUnit 3.4.1

奇怪的是,我有另一个项目,它的设置方式与这个项目相同,并且运行良好.

The weird thing is, that I have another project which is set up the same way as this one and it works just fine.

我还下载了 NUnit 3.4.1 并安装了它.当我跑

I also downloaded NUnit 3.4.1 and installed it. When I run

nunit3-console.exe Trading.Tools.Test.dll

一切正常.有什么想法我可以做什么吗?

everything works just fine. Any ideas what I can do?

非常感谢康斯坦丁

编辑 #1

这是尝试运行所有测试时 Visual Studio 的完整控制台输出.

Here is the full console output from Visual Studio when trying to run all test.

Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run: 
Trading.Tools.Test.dll, Trading.Tools.dll are built for Framework Framework45 and Platform X64.
 Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
NUnit Adapter 3.4.0.0: Test discovery starting
NUnit failed to load w:\Repos\trading.tools\Trading.Tools.Test\bin\x64\Debug\Trading.Tools.Test.dll
Assembly contains no NUnit 3.0 tests: w:\Repos\trading.tools\Trading.Tools\bin\x64\Debug\Trading.Tools.dll
NUnit Adapter 3.4.0.0: Test discovery complete

如您所见,很明显 NUnit 需要 x86 构建,但我为 x64 平台构建.同样,如果我使用 nunit3-console.exe 执行它,我的 x64 构建就可以正常工作.

As you can see it is very obvious that NUnit expects a x86 build, but I build for a x64 platform. And again, my x64 build works just fine if I execute it using nunit3-console.exe.

我在 csproj 文件中看到的是:

What I see in the csproj file is this:

<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\packages\NUnit.3.4.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>

这里奇怪的是它指定使用 Version=2.6.4.14350 但引用 3.4.1 dll.

The weird thing here is that it specifies using Version=2.6.4.14350 but referencing a 3.4.1 dll.

那么接下来的问题是如何让 NUnit 执行我的 x64 构建?有什么想法吗?

So the next question from this point is how can I make NUnit execute my x64 build? Any ideas?

推荐答案

我遇到了类似的问题,关键是 Visual Studio 中的 Test Runner 表明只有 x86组件将被测试.我由此假设它会强制使用 x86 NUnit runner.要更改此设置(至少在 VS2015 和 VS2017 中),请转到 Test > Test Settings > Default Processor Architecture > X64.

I had a similar issue, the key is the fact that it is the Test Runner in Visual Studio that is stating that only x86 assemblies will be tested. I am assuming from this that it then forces the use of the x86 NUnit runner. To change this (in VS2015 and VS2017 at least), go to Test > Test Settings > Default Processor Architecture > X64.

这篇关于NUnit 无法加载 DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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