【发布时间】:2008-10-07 00:56:36
【问题描述】:
我以前使用过 NUnit,但有一段时间没有使用过,而且从未在这台机器上使用过。我在Program Files 下解压缩了 2.4.8 版,但在尝试加载测试时一直出现此错误。
无法加载文件或程序集 '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”添加到我的 PATH(并重新启动)。请注意,如果我将测试程序集复制到该文件夹中,那么
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 /出:test.dll test.cs我尝试了 .msi 和 .zip 文件,结果相同。
【问题讨论】:
-
愚蠢的问题,但是您在测试项目中添加了对 NUnit 的引用?
标签: nunit