C# 以NUnit.Console-3.8.0作为目标可执行文件运行dotcover会引发异常
我正在尝试使用NUnit.Console-3.9.0\nunit3 Console runner.exe作为目标可执行文件运行dotcover 附件代码和截图我的工作到目前为止C# 以NUnit.Console-3.8.0作为目标可执行文件运行dotcover会引发异常,c#,c#-4.0,nunit,nunit-console,dotcover,C#,C# 4.0,Nunit,Nunit Console,Dotcover,我正在尝试使用NUnit.Console-3.9.0\nunit3 Console runner.exe作为目标可执行文件运行dotcover 附件代码和截图我的工作到目前为止 using System; namespace secondApp { public class Class1 { public int add(int a, int b) { return a + b; } pu
using System;
namespace secondApp
{
public class Class1
{
public int add(int a, int b)
{
return a + b;
}
public int sub(int a, int b)
{
return a - b;
}
}
}
这是相应的测试文件
using NUnit.Framework;
using secondApp;
namespace Tests
{
public class Tests
{
private Class1 class1;
[SetUp]
public void Setup()
{
class1 = new Class1();
}
[Test]
public void AddTest1()
{
int val = class1.add(1, 2);
Assert.AreEqual(val, 3);
}
[Test]
public void SubTest()
{
int val = class1.sub(1, 2);
Assert.AreEqual(val, -1);
}
}
}
这是文件_coverage.xml文件(dotcover文件_coverage.xml),这是发生错误的地方
<?xml version="1.0" encoding="utf-8"?>
<AnalyseParams>
<TargetExecutable>..\3rdparty\NUnit.Console-3.9.0\nunit3-console.exe
</TargetExecutable>
<TargetArguments>.\Testfile.nunit</TargetArguments>
<Output>output.dcvr</Output>
<Filters>
<IncludeFilters>
<FilterEntry>
<ModuleMask>*</ModuleMask>
<ClassMask>*</ClassMask>
<FunctionMask>*</FunctionMask>
</FilterEntry>
</IncludeFilters>
</Filters>
</AnalyseParams>
您的异常日志显示找不到nunit.framework程序集,请检查其是否存在于引用中,如果存在,请转到工具->选项->测试,并取消选中以下屏幕截图中突出显示的选项:
如果有帮助,请告诉我。测试文件的路径表明它是.NET核心文件。此时无法从NUnit3控制台运行程序执行.NET核心测试,您必须使用
dotnet test
。感谢您的回答,我尝试在命令行中再次运行dotcover,但它没有帮助。现在有一个用于.NET核心项目的测试。这是真的。测试版。然而,在被问到这个问题的时候,这不是真的。只是想指出正确的方向,如果有人在寻找它的话。;)
<NUnitProject>
<Settings activeconfig="Debug" />
<Config name="Debug" binpathtype="Auto">
<assembly path=".\bin\Debug\netcoreapp2.1\Test.dll" />
</Config>
</NUnitProject>
dotcover c file_coverage.xml
JetBrains dotCover Console Runner 2018.2.3. Build 777.0.20180912.160624
Copyright (c) 2009-2019 JetBrains s.r.o. All rights reserved.
[JetBrains dotCover] Coverage session started [1/8/2019 12:19:36 PM]
NUnit Console Runner 3.8.0
Copyright (c) 2018 Charlie Poole, Rob Prouse
Runtime Environment
OS Version: Microsoft Windows NT 10.0.16299.0
CLR Version: 4.0.30319.42000
Test Files
c:\rough-work\secondApp\Test\Testfile.nunit
Errors, Failures and Warnings
1) Error : c:\rough-work\secondApp\Test\Testfile.nunit
NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests.
----> System.IO.FileNotFoundException : Could not load file or assembly 'nunit.framework' or one of its dependencies. The system cannot find the file specified.
--NUnitEngineException
Server stack trace:
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.TestDomainRunner.LoadPackage()
at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.AbstractTestRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Agents.RemoteTestAgent.Run(ITestEventListener listener, TestFilter filter)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)
--FileNotFoundException
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(String typeName, Object[] args)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
Test Run Summary
Overall result: Failed
Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Start time: 2019-01-08 06:49:38Z
End time: 2019-01-08 06:49:38Z
Duration: 0.603 seconds
Results (nunit3) saved as TestResult.xml
[JetBrains dotCover] Coverage session finished [1/8/2019 12:19:40 PM]
[JetBrains dotCover] Analyzed application exited with code '-100'
[JetBrains dotCover] Coverage results post-processing started [1/8/2019 12:19:40 PM]
[JetBrains dotCover] Coverage results post-processing finished [1/8/2019 12:19:40 PM]