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,版本= 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。
如果您需要更多相关信息,请与我们联系。
答案 0 :(得分:1)
在https://github.com/nunit/nunit/issues/2763
找到答案 NUnit Console
没有运行.NET Core测试 - 您需要使用dotnet测试。看看这个页面:
https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard