我将用于nunit-console
在我的解决方案中运行所有测试。
我这样做了:
c:\some\path>nunit-console-x86.exe MySolution.sln
NUnit-Console version 2.6.2.12296
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR Version: 2.0.50727.5466 ( Net 3.5 )
ProcessModel: Default DomainUsage: Default
Execution Runtime: net-3.5
Could not load file or assembly 'MyNamespace.Administration, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
nunit-x86.exe
所以,我决定尝试一下File > Open Project > MySolution.sln
,得到了这个:
---------------------------
NUnit
---------------------------
Test load failed!
System.IO.FileNotFoundException : Could not load file or assembly
'MyNamespace.Administration, Version=0.0.0.1, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. The system cannot
find the file specified.
For further information, use the Exception Details menu item.
---------------------------
OK
---------------------------
发生了什么,我该如何解决?(无需维护 MySolution.nunit 文件)
更多信息
MyNamespace.Administration
甚至不是包含测试的 dll 之一,这意味着 nunit 无法尝试加载它以查找要运行的测试。知道这一点后,我编辑了由nunit-x86.exe
(MySolution.nunit) 创建的文件并删除了所有没有测试的 dll。果然,测试工作(在 gui 和控制台中)。这对我来说是不可接受的,因为这意味着我必须保留另一个配置文件。Nunit 支持 .sln 文件应该避免这种情况。- 我的测试使用 TestDriven.Net 运行良好(但我真的需要使用 nunit-console 运行它们)
我已经看过这个答案,但我无法理解融合日志查看器所说的内容。发布该日志会有所帮助吗?程序集绑定日志查看器,列出了正在创建的 3 个文件:- nunit-agent-x86.exe,这个似乎试图
MyNamespace.Administration.dll/EXE
在 nunit 目录中找到 - Tests_24398275 x2 - 一个在我的项目文件夹中寻找 nunit.core,另一个在我的项目文件夹中寻找 unit.core.interfaces。我很少注意这两个,因为它们也出现在我手动编辑的 .nunit 项目中)。
- nunit-agent-x86.exe,这个似乎试图
- (根据 andreister 的评论)问题似乎出在项目/程序集本身而不是创建方法上。如果我创建一个 .nunit 项目并尝试添加
MyNamespace.Administration
到它(使用“添加程序集...”或“添加 VS 项目...”)它会失败。 - 直接调用就
nunit-console-x86 somepath/bin/Debug/MyNamespace.Administration.dll
可以了。