从 teamcity 运行测试时设置方法失败 [英] SetUp method failed while running tests from teamcity
问题描述
我通过 nunit 在本地成功运行了测试.但是,当我尝试通过 teamcity 运行它们时,有些测试通过了,但有些测试失败了,出现以下错误.
I am successfuly running tests locally via nunit. But when I try to run them through teamcity some tests are passed but some failed by giving the following error.
设置方法失败.System.Runtime.InteropServices.COMException:由于以下错误,从 IClassFactory 创建具有 CLSID {0002DF01-0000-0000-C000-000000000046} 的 COM 组件的实例失败:800704a6.在 WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, LogonDialogHandler logonDialogHandler, Boolean createInNewProcess)在 WatiN.Core.IE..ctor()在 C:\Tests.vb:line 14 中的 test.Setup()
SetUp method failed. System.Runtime.InteropServices.COMException : Creating an instance of the COM component with CLSID {0002DF01-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 800704a6. at WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri, LogonDialogHandler logonDialogHandler, Boolean createInNewProcess) at WatiN.Core.IE..ctor() at test.Setup() in C:\Tests.vb:line 14
推荐答案
不确定这是否已解决,但我在 2 个不同的测试装置中遇到相同的错误,1 个是用 C# 编写的,另一个是用 VB.NET 编写的.
Not sure if this has been resolved or not but I was having the same error in 2 different test fixtures 1 written in C# the other written in VB.NET.
对于 C# 固定装置,我需要做的就是在创建 WatIn.IE 的新实例时,将第二个参数添加到:IE var ie = new IE(url, true强>)true"告诉 WatIn 去createInNewProcess",它会在一个新进程中打开下一个 IE.
For the C# fixture all I need to do to resolve the issue is when I create a new instance of WatIn.IE, I added the second parameter to: IE var ie = new IE(url, true) The "true" tells WatIn to "createInNewProcess" which opens the next IE in a new process.
然而,由于某种原因,这对用 VB.NET 编写的测试装置不起作用.对于这个装置,我必须在我们的一个 C# 库中调用一个方法来强制每个测试TearDown"方法中的 IE 关闭.下面的 C# 代码成功了:
This, however, did not work for the test fixture written in VB.NET for some reason. For this fixture I had to call a method in one of our C# libraries to force an IE closure in each Tests "TearDown" method. The following C# code did the trick:
public static void CloseInternetExplorers()
{
var processes = from process in Process.GetProcesses()
where process.ProcessName == "iexplore"
select process;
foreach (var process in processes)
{
while (!process.HasExited)
{
process.Kill();
process.WaitForExit();
}
}
}
这篇关于从 teamcity 运行测试时设置方法失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!