我以前用过 NUnit,但没用过一段时间,也从来没有在这台机器上用过。我在 2.4.8 下解压缩了 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”添加到我的 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 文件,结果相同。