无法加载文件或程序集 MyNunitTest.dll 或其依赖项之一

Could not load file or assembly MyNunitTest.dll or one of its dependencies

我无法在最新的 .NET 中 运行 Nunit。以下是我执行的所有步骤:

  1. 新项目 > Class 库(包)
  2. 添加 NUnit 3.0.1
  3. 添加 class:

内容:

using NUnit.Framework;

namespace MyNunitTest
{
    [TestFixture]
    public class TestClass
    {
        [Test]
        public void TestMethod()
        {
            Assert.That(true, Is.True);
        }
    }
}
  1. 运行全部

错误:

System.IO.FileNotFoundException: Could not load file or assembly MyNunitTest.dll or one of its dependencies. The system cannot find the file specified.

我在使用Resharper 9.2时遇到了同样的问题,也许你更新后就会解决问题。

这里主要问题的解决方法是选择了错误的项目类型。

要添加单元测试项目,请添加新的单元测试项目,而不是class 库或任何其他类型的项目。一切都会按预期工作。