从 teamcity 运行测试时,SetUp 方法失败

发布于 2024-10-05 16:02:38 字数 407 浏览 1 评论 0原文

我通过 nunit 在本地成功运行测试。但是,当我尝试通过 teamcity 运行它们时,一些测试通过了,但有些测试失败,并出现以下错误。

设置方法失败。 System.Runtime.InteropServices.COMException:从 IClassFactory 创建 CLSID 为 {0002DF01-0000-0000-C000-000000000046} 的 COM 组件实例失败,原因如下:800704a6。 在WatiN.Core.IE.CreateNewIEAndGoToUri(Uri uri,LogonDialogHandler logonDialogHandler,布尔createInNewProcess) 在 WatiN.Core.IE..ctor() 在 C:\Tests.vb 中的 test.Setup() 处:第 14 行

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不醒的梦 2024-10-12 16:02:39

不确定这个问题是否已解决,但我在 2 个不同的测试装置中遇到了相同的错误,其中 1 个是用 C# 编写的,另一个是用 VB.NET 编写的。

对于 C# 固定装置,解决问题所需要做的就是在创建 WatIn.IE 的新实例时,将第二个参数添加到: IE var ie = new IE(url, true)
“true”告诉 WatIn “createInNewProcess”,在新进程中打开下一个 IE。

然而,由于某种原因,这对于用 VB.NET 编写的测试装置不起作用。
对于此装置,我必须调用 C# 库之一中的方法,以在每个测试“TearDown”方法中强制 IE 关闭。
下面的 C# 代码就达到了目的:

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();
    }
  }
}

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.

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.

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();
    }
  }
}
软糯酥胸 2024-10-12 16:02:39

您是否尝试过通过 teamcity 服务器上的 Nunit 运行测试?这可能会为您提供更多信息。

Have you tried to run the tests via Nunit on the teamcity server? This might give you more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文