【发布时间】:2016-08-03 03:48:07
【问题描述】:
尝试在 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
奇怪的是,我有另一个项目,它的设置方式与这个相同,而且效果很好。
我还下载了 NUnit 3.4.1 并安装了它。当我跑步时
nunit3-console.exe Trading.Tools.Test.dll
一切正常。 有什么想法我能做什么?
非常感谢 康斯坦丁
编辑#1
这是尝试运行所有测试时 Visual Studio 的完整控制台输出。
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 构建就可以正常工作。
我在csproj 文件中看到的是这样的:
<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。
所以从这一点开始的下一个问题是如何让 NUnit 执行我的 x64 构建?有什么想法吗?
【问题讨论】:
-
删除您的 bin 和 obj 文件夹并重新构建它并尝试运行。我认为它会起作用
-
您是否检查过该文件是否存在以及您构建/运行程序时的时间戳?
-
@ShakirAhamed,我删除了这两个目录。还是失败了……
-
从您的参考文件夹中删除 Nunit 参考,然后使用 Install-Package NUnit Nuget 包管理器再次安装它
-
您的任何测试或被测代码是否尝试加载文件或程序集?如果是这样,他们是否假定当前目录?
标签: c# visual-studio-2013 nunit