.NET Core 是否与 NUnit 控制台运行器一起工作?
Does .NET Core work with the NUnit console runner?
我有一个很简单的测试!
[Test]
public void TestMethod1()
{
Assert.IsTrue(false);
}
当我尝试 运行 使用 nunit3-console.exe 时,出现以下错误。
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
我正在 运行ning .NET Core 2.1,使用 NUnit Console Runner 3.9 和 NUnit 测试适配器 3.1。我确实进行了 Google 搜索并得到了相互矛盾的答案。我错过了什么吗?
最近发布的 NUnit 3.11 关于 releases page 的说明:
PlatformAttribute is available on .NET Standard 2.0 and now detects .NET Core
尝试使用 NUnit 3.11。
我还在讨论 .NET Standard 和 .NET Core 支持的 NUnit 文档中找到 this page。粗略的阅读似乎表明它是受支持的。
更新
使用 dotnet 核心 Coverlet is your friend. Also see this。
我已经转向云和 Azure DevOps。是的,它只是带有很多口红的 TFS,但它是 Cloud。 (嘘:GitHub 行动是我的未来)。
这是我的单元测试任务(在 yaml 管道中),运行是我的 NUnit 测试套件。本质上它正在执行 dotnet test
,Coverlet 与之完全集成。
# UnitTests
- task: DotNetCoreCLI@2
displayName: 'Unit Tests'
inputs:
command: test
projects: '$(APEX_SOLUTION)'
arguments: '--no-restore -c $(BUILD_CONFIGURATION) /p:CollectCoverage=true /p:CoverletOutput=$(Agent.TempDirectory)/ /p:CoverletOutputFormat=opencover /p:Threshold=50 /p:ThresholdType=branch /p:ThresholdStat=Average /p:Exclude="[DevOpsOnboarding.Views]*"'
testRunTitle: 'Unit Tests $(Build.DefinitionName) - $(Build.BuildNumber)'
Coverlet 还允许您一步生成 OpenCover 输出。完成此任务后,我可以 运行 ReportGenerator。
转换为 Jenkins Batch Step 应该很简单。
我联系了 NUnit 社区并得到了这个答案:Does NUnit Console work with .NET Core? #487
NUnit 控制台是使用完整的 .NET Framework 编译的,目前不支持 .NET Core。要从命令行 运行 .NET Core 测试,您需要使用 dotnet test
。有关如何执行此操作的信息,请参阅 .NET Core and .NET Standard (NUnit wiki)。
我们正在考虑创建一个基于 .NET Core 的控制台 运行,但它仍处于规划阶段。
我有一个很简单的测试!
[Test]
public void TestMethod1()
{
Assert.IsTrue(false);
}
当我尝试 运行 使用 nunit3-console.exe 时,出现以下错误。
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
我正在 运行ning .NET Core 2.1,使用 NUnit Console Runner 3.9 和 NUnit 测试适配器 3.1。我确实进行了 Google 搜索并得到了相互矛盾的答案。我错过了什么吗?
最近发布的 NUnit 3.11 关于 releases page 的说明:
PlatformAttribute is available on .NET Standard 2.0 and now detects .NET Core
尝试使用 NUnit 3.11。
我还在讨论 .NET Standard 和 .NET Core 支持的 NUnit 文档中找到 this page。粗略的阅读似乎表明它是受支持的。
更新
使用 dotnet 核心 Coverlet is your friend. Also see this。
我已经转向云和 Azure DevOps。是的,它只是带有很多口红的 TFS,但它是 Cloud。 (嘘:GitHub 行动是我的未来)。
这是我的单元测试任务(在 yaml 管道中),运行是我的 NUnit 测试套件。本质上它正在执行 dotnet test
,Coverlet 与之完全集成。
# UnitTests
- task: DotNetCoreCLI@2
displayName: 'Unit Tests'
inputs:
command: test
projects: '$(APEX_SOLUTION)'
arguments: '--no-restore -c $(BUILD_CONFIGURATION) /p:CollectCoverage=true /p:CoverletOutput=$(Agent.TempDirectory)/ /p:CoverletOutputFormat=opencover /p:Threshold=50 /p:ThresholdType=branch /p:ThresholdStat=Average /p:Exclude="[DevOpsOnboarding.Views]*"'
testRunTitle: 'Unit Tests $(Build.DefinitionName) - $(Build.BuildNumber)'
Coverlet 还允许您一步生成 OpenCover 输出。完成此任务后,我可以 运行 ReportGenerator。
转换为 Jenkins Batch Step 应该很简单。
我联系了 NUnit 社区并得到了这个答案:Does NUnit Console work with .NET Core? #487
NUnit 控制台是使用完整的 .NET Framework 编译的,目前不支持 .NET Core。要从命令行 运行 .NET Core 测试,您需要使用 dotnet test
。有关如何执行此操作的信息,请参阅 .NET Core and .NET Standard (NUnit wiki)。
我们正在考虑创建一个基于 .NET Core 的控制台 运行,但它仍处于规划阶段。