我以前使用过NUnit,但已经有一段时间了,并且从未在这台电脑上使用过。我将2.4.8版本解压到了Program Files
文件夹下,但当我尝试加载我的测试时,不断出现以下错误:
无法加载文件或程序集“nunit.framework,Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77”或其某个依赖项。系统找不到指定的文件**
为了简化问题,我编译了最基本的测试文件。
using NUnit.Framework;
namespace test
{
[TestFixture]
public class Tester
{
[Test]
public void ATest()
{
Assert.IsTrue(false, "At least the test ran!");
}
}
}
我已将 "C:\Program Files\NUnit-2.4.8-net-2.0\bin" 添加到我的路径中(并重新启动)。请注意,如果我将测试程序集复制到该文件夹中,则以下命令可以正常工作:
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console test.dll
但是以下命令却失败了:
C:\Program Files\NUnit-2.4.8-net-2.0\bin>nunit-console c:\dev\nunit_test\test.dll
以及
C:\dev\nunit_test>nunit_console test.dll
假设我将 NUnit.Framework DLL 文件复制到我的项目的
bin
文件夹中,那么这个问题就会解决。但是,我记得过去不需要这样做。而且,在 GUI 中我也遇到了相同的错误。GUI 不应该知道框架在哪里吗(也就是说,在同一个文件夹中)?我没有使用 Visual Studio。我使用以下命令来编译测试项目:
%windir%\Microsoft.NET\Framework\v2.0.50727\csc.exe /r:"C:\Program Files\NUnit-2.4.8-net-2.0\bin\nunit.framework.dll" /t:library /out:test.dll test.cs
我尝试了 .msi 和 .zip 文件,但结果相同。