如何 运行 NUnit 测试作为一个独立的可执行文件?
How to run NUnit tests as a stand alone executable?
我很好奇如何 运行 NUnit 不是从命令行而是作为单个可执行文件(控制台应用程序)进行测试。我发现这个 article from 2012 展示了如何使用 ConsoleRunner 运行 它。然而,我 运行 进入以下错误,即使我确保安装和引用了正确版本的 nunit.core。
"Could not load file or assembly 'nunit.core, Version=2.6.4.0, Culture=neutral, PublicKeyToken=ab07c6840cd6369d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"nunit.core, Version=2.6.4.0, Culture=neutral, PublicKeyToken=ab07c6840cd6369d"
所以我的问题是有没有其他方法可以将 NUnit 测试作为单个可执行文件来实现?我的代码片段如下,
[TestFixture]
public class Test
{
public static void Main(string[] args)
{
NUnit.ConsoleRunner.Runner.Main( new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,
});
}
[Test]
public void SampleTest()
{}
旧文章的问题在于作者很少回过头来将它们标记为过时。这篇文章提到了 NUnit V2,它是 NUnit 3 的前身。NUnit 3 是一个完整的重写。
创建可执行测试的方法是使用 NUnitLite。您将测试程序集创建为控制台并引用 nunit 框架和 nunilitlite 包。有关详细信息,请参阅文档... https://docs.nunit.org/articles/nunit/running-tests/NUnitLite-Runner.html
我很好奇如何 运行 NUnit 不是从命令行而是作为单个可执行文件(控制台应用程序)进行测试。我发现这个 article from 2012 展示了如何使用 ConsoleRunner 运行 它。然而,我 运行 进入以下错误,即使我确保安装和引用了正确版本的 nunit.core。
"Could not load file or assembly 'nunit.core, Version=2.6.4.0, Culture=neutral, PublicKeyToken=ab07c6840cd6369d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"nunit.core, Version=2.6.4.0, Culture=neutral, PublicKeyToken=ab07c6840cd6369d"
所以我的问题是有没有其他方法可以将 NUnit 测试作为单个可执行文件来实现?我的代码片段如下,
[TestFixture]
public class Test
{
public static void Main(string[] args)
{
NUnit.ConsoleRunner.Runner.Main( new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,
});
}
[Test]
public void SampleTest()
{}
旧文章的问题在于作者很少回过头来将它们标记为过时。这篇文章提到了 NUnit V2,它是 NUnit 3 的前身。NUnit 3 是一个完整的重写。
创建可执行测试的方法是使用 NUnitLite。您将测试程序集创建为控制台并引用 nunit 框架和 nunilitlite 包。有关详细信息,请参阅文档... https://docs.nunit.org/articles/nunit/running-tests/NUnitLite-Runner.html