Piy*_*ade 6 .net c# console automation nunit
我有一个简单的 Nunit 项目,其中仅包含一个测试。我想使用命令执行我的代码,因此我在 Windows 10 计算机上安装了 \xe2\x80\x98Nunit-console.exe\xe2\x80\x99 。安装后,使用以下命令在命令提示符下执行代码
\nnunit3-console.exe "G:\\LiveProjects\\NUnitTestProject2\\NUnitTestProject2\\bin\\Debug\\netcoreapp3.1\\NUnitTestProject2.dll"\nlike so\nRun Code Online (Sandbox Code Playgroud)\n执行此命令后,我发现以下错误消息:
\nNUnit.Engine.NUnitEngineException : The NUnit 3 driver encountered an error while executing reflected code.\n ----> System.InvalidCastException : Unable to cast transparent proxy to type 'System.Web.UI.ICallbackEventHandler'.\n--NUnitEngineException\nThe NUnit 3 driver encountered an error while executing reflected code.\nlike so\nRun Code Online (Sandbox Code Playgroud)\n请参考我下面的代码:
\n[TestFixture] \n public class Tests\n {\n [SetUp]\n public void Setup()\n {\n\n Console.WriteLine("Welcome setup");\n\n }\n\n [Test]\n public void Test1()\n {\n \n Console.WriteLine("Welcome first Test ");\n Assert.Pass();\n }\n }\nlike so\nRun Code Online (Sandbox Code Playgroud)\n我的项目的配置详细信息:
\n另外,我尝试在 Visual Studio 2019 中禁用 \xe2\x80\x98code 覆盖 \xe2\x80\x99 选项,但是 - 我无法看到它。任何人都可以建议 - \xe2\x80\x98code 在哪里Visual Studio 2019 中提供了coverage\xe2\x80\x99 选项。
\n查理的评论是正确的 - 但不幸的是仍然无法解决您的问题。您的测试套件针对 .NET Core - NUnit 控制台尚不支持。(尽管有一个提供支持的测试版。)
目前,最好的解决方案是使用 来运行dotnet test,而不是使用 nunit 控制台。有关更多详细信息,请参阅此处的指南: https: //docs.nunit.org/articles/nunit/getting-started/dotnet-core-and-dotnet-standard.html
NUnit 3 测试适配器的版本 3.16.1 与您安装的控制台包使用的引擎版本 3.11.1 不兼容。
您必须将控制台运行程序降级到 3.10 或将适配器升级到 3.17。
有关详细说明,请参阅我的博客文章:http://charliepoole.org/technical/nunit-engine-version-conflicts-in-visual-studio.html