C# 在NUnit.ConsoleRunner.3.2.1中运行测试时,NUnit runner失败

C# 在NUnit.ConsoleRunner.3.2.1中运行测试时,NUnit runner失败,c#,selenium-webdriver,nunit-console,C#,Selenium Webdriver,Nunit Console,这就是困扰我的测试套件的错误 [07:34:36][Step 4/4] Exception has been thrown by the target of an invocation. [07:34:36][Step 4/4] [07:34:36][Step 4/4] Server stack trace: [07:34:36][Step 4/4] at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] a

这就是困扰我的测试套件的错误

[07:34:36][Step 4/4] Exception has been thrown by the target of an invocation.
[07:34:36][Step 4/4] 
[07:34:36][Step 4/4] Server stack trace: 
[07:34:36][Step 4/4]    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
[07:34:36][Step 4/4]    at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[07:34:36][Step 4/4]    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
[07:34:36][Step 4/4]    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
[07:34:36][Step 4/4]    at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
[07:34:36][Step 4/4]    at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
[07:34:36][Step 4/4]    at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
[07:34:36][Step 4/4]    at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
[07:34:36][Step 4/4]    at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
[07:34:36][Step 4/4]    at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Run(ITestEventListener listener, String filter)
[07:34:36][Step 4/4]    at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
[07:34:36][Step 4/4]    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
[07:34:36][Step 4/4]    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
[07:34:36][Step 4/4] 
[07:34:36][Step 4/4] Exception rethrown at [0]: 
[07:34:36][Step 4/4]    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
[07:34:36][Step 4/4]    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
[07:34:36][Step 4/4]    at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
[07:34:36][Step 4/4]    at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)
[07:34:36][Step 4/4] 
[07:34:36][Step 4/4] Test Run Summary
[07:34:36][Step 4/4]   Overall result: Failed
[07:34:36][Step 4/4]   Test Count: 0, Passed: 0, Failed: 0, Inconclusive: 0, Skipped: 0
[07:34:36][Step 4/4]   Start time: 2016-05-19 14:15:21Z
[07:34:36][Step 4/4]     End time: 2016-05-19 14:34:35Z
[07:34:36][Step 4/4]     Duration: 1154.123 seconds
所以我对这个错误的了解

我只有在NUnit.ConsoleRunner.3.2.1中运行测试套件时才会遇到此异常。在VS中运行测试时,我没有遇到此错误

只有在同一版本中同时运行两个测试套件时,才会出现此错误。我只是在运行整个程序时才得到这个例外。我已经做了很多次测试,只运行一个套件,然后运行另一个套件。除此之外,所有的东西都起作用,但所有的东西在一起都有这个问题


这似乎不是由测试代码中的任何事件触发的。我已经在每个测试用例的开始和结束以及
onetimeeardown
中添加了日志记录,在运行之后,我可以在日志中看到所有测试用例都已完成,所有拆卸都已完成。当NUnit生成测试结果/报告时,似乎会出现此问题。关于这个例外情况的任何信息都非常有用。我猜最坏的情况是我将测试套件分成不同的分支,并独立运行它们,但我更希望它们都通过一个作业而不是多个作业运行

因此,我最终与NUnit开发人员一起打开了一份bug报告

对我有效的是使用标志
--inprocess
执行我的测试,该标志暂时解决了这个问题。他们刚刚在NUnit ConsoleRunner 3.4.1的发行版中将这个bug标记为“已关闭”。我已经删除了
--inprocess
,但没有看到问题的出现,尽管让我确认一下,目前我的测试套件只针对Firefox运行,因为Chrome v 51在会话[0]中运行时存在一个不同的问题,这就是我在TeamCity服务器上运行它们时如何启动Chrome

希望这有帮助