在NUnit.ConsoleRunner.3.2.1中运行测试时,NUnit运行程序失败

时间:2016-05-19 16:32:51

标签: 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[] 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中运行测试时,我没有收到此错误。

只有当我在同一个版本中同时运行两个测试套件时才会出现此错误。当我运行整个事情时,我只会得到这个例外。我已经完成了许多测试,并将它们运行在一个套件中,然后运行另一个套件。除了所有工作,但他们都有这个问题。

似乎这不是我的测试代码中的任何事件触发的。我已将日志记录添加到每个测试用例的开始和结束以及OneTimeTearDown,并且在运行后我可以在日志中看到所有测试用例已完成且所有拆除已完成。当NUnit生成测试结果/报告时,似乎会出现此问题。有关此异常的任何信息都会很棒。我猜最糟糕的情况是我将我的测试套件分成不同的分支并独立运行它们但我宁愿让它们全部用一个工作而不是多个工作。

1 个答案:

答案 0 :(得分:1)

所以我最终与NUnit开发人员一起打开了一个错误报告。 https://github.com/nunit/nunit/issues/1509

对我有用的是使用暂时解决此问题的标记--inprocess执行我的测试。他们只是将这个错误标记为"关闭"随着NUnit ConsoleRunner 3.4.1的发布。我已经删除--inprocess并且没有看到问题出现虽然让我有资格认为目前我的测试套件仅针对Firefox运行,因为在会话[0]中运行的Chrome v 51存在不同的问题是我在运行它们的TeamCity服务器启动chrome。

希望这有帮助