【发布时间】:2021-02-13 01:48:51
【问题描述】:
我有一个简单的 Nunit 项目,它只包含一个测试。我想使用命令执行我的代码,所以我在我的 Windows 10 机器上安装了“Nunit-console.exe”。安装后,使用以下命令在命令提示符下执行代码
nunit3-console.exe "G:\LiveProjects\NUnitTestProject2\NUnitTestProject2\bin\Debug\netcoreapp3.1\NUnitTestProject2.dll"
like so
执行此命令后,我发现以下错误消息:
NUnit.Engine.NUnitEngineException : The NUnit 3 driver encountered an error while executing reflected code.
----> System.InvalidCastException : Unable to cast transparent proxy to type 'System.Web.UI.ICallbackEventHandler'.
--NUnitEngineException
The NUnit 3 driver encountered an error while executing reflected code.
like so
请参考我下面的代码:
[TestFixture]
public class Tests
{
[SetUp]
public void Setup()
{
Console.WriteLine("Welcome setup");
}
[Test]
public void Test1()
{
Console.WriteLine("Welcome first Test ");
Assert.Pass();
}
}
like so
我的项目的配置详情:
- Microsoft.NET Framework 4.7.0 版
- 操作系统: 窗口 10
- IDE:Visual Studio 2019
- 使用 Nunit 框架进行单元测试
- NUnit3TestAdapter(版本)3.16.1
- Microsoft.NET.Test.Sdk(版本)16.5.0
- NUnit.Console(版本)3.11.1
- 目标 .NET 框架(版本)3.1
此外,我尝试在 Visual Studio 2019 中禁用“代码覆盖率”选项,但是 - 我无法在其中看到它。谁能建议 - Visual Studio 2019 中的“代码覆盖率”选项在哪里可用。
【问题讨论】:
标签: c# .net automation console nunit