【问题标题】:NUnit3 throws exception System.Runtime, Version=4.2.0.0 not found while trying to run test in NUnit3 consoleNUnit3 在尝试在 NUnit3 控制台中运行测试时抛出异常 System.Runtime, Version=4.2.0.0 not found
【发布时间】:2018-04-19 11:31:22
【问题描述】:
Environment:
.Net Core 2.0
visual Studio Professional 2017
NUnit3
OpenCover (For code coverage)
ReportGenerator(For code coverage report)

嗨,Nunit 团队, 我对 MS Test 框架非常熟悉,并且已经在这方面进行了广泛的研究,但正在测试 NUnit 框架的适用性,因此想围绕它做一个小的 POC。我创建了一个小型类库和一个单元测试项目。以下是已安装的 NuGet 包:

NUnit 3.7.1

但是当我尝试从控制台运行器运行测试用例时,如下所示,我收到异常提示 System.Runtime, Version=4.2.0.0 未找到程序集。

C:\Users\UN\.nuget\packages\nunit.consolerunner\3.8.0\tools>nunit3-console.exe D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll

异常详情:

Errors, Failures and Warnings

Invalid : D:\Code_Trials\BoMLibrary\BomTest\bin\Debug\netcoreapp2.0\BomTest.dll
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
----> Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Settings
DisposeRunners: True
WorkDirectory: C:\Users\Smukherjee.nuget\packages\nunit.consolerunner\3.8.0\tools
ImageRuntimeVersion: 4.0.30319
ImageTargetFrameworkName: .NETCoreApp,Version=v2.0
ImageRequiresX86: False
ImageRequiresDefaultAppDomainAssemblyResolver: False
NumberOfTestWorkers: 4

我真的不知道为什么会这样?不管我怎么尝试都无法通过这个错误。此外,当我尝试从 Nuget 安装程序集时,我什至找不到版本为 4.2.0.0 的程序集。

尝试安装 System.Runtime 的 4.3.0.0 版本,但没有成功。你能帮忙吗?

奇怪的是,我有一个示例单元测试项目(作为 opencover nuget 安装的一部分),它针对 .Net Framework 4.5 并安装了 NUnit2.6.7 包,当我尝试使用 NUnit3 控制台运行它时,它就像魅力一样。

即使安装 NUnit3 最新稳定版 3.10.1.0 也无济于事。此外,这肯定不是 Opencover 问题,因为 opencover 控制台只是将测试运行请求传递给 NUnit 控制台。所以问题必须围绕 NUnit。

如果您需要这方面的更多信息,请告诉我。

【问题讨论】:

    标签: visual-studio-2017 nunit-3.0 .net-core-2.0 opencover


    【解决方案1】:

    在这里找到答案https://github.com/nunit/nunit/issues/2763

    NUnit Console 不运行 .NET Core 测试 - 您需要改用 dotnet test。看看这个页面:

    https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多