当我在Visual Studio中尝试运行单元测试时,出现以下错误信息:
NUnit failed to load w:\Repos\trading.tools\Trading.Tools.Test\bin\x64\Debug\Trading.Tools.Test.dll
我正在使用
- Visual Studio Community 2013
- NUnit Adapter 3.4.0.0
- NUnit 3.4.1
奇怪的是,我有另一个设置方式与这个项目相同的项目,它可以正常工作。
我还下载了NUnit 3.4.1并安装了它。当我运行时
nunit3-console.exe Trading.Tools.Test.dll
一切都运行良好。有什么想法吗?
非常感谢 Konstantin
编辑 #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构建呢?有什么想法吗?