使用 WatiN 进行 NUnit 测试,从 Dev10 运行正常,但是当 NUnit 从“C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0\nunit.exe”启动时,会出现以下错误:

发布于 2024-09-02 10:11:38 字数 1629 浏览 5 评论 0原文

我在 Nunit 测试中有以下代码...

    string url = "";
    url = @"http://localhost/ClientPortalDev/Account/LogOn";
    ieStaticInstanceHelper = new IEStaticInstanceHelper();
    ieStaticInstanceHelper.IE = new IE(url);
    ieStaticInstanceHelper.IE.TextField(Find.ById("UserName")).TypeText("abc");
    ieStaticInstanceHelper.IE.TextField(Find.ById("Password")).TypeText("defg");
    ieStaticInstanceHelper.IE.Button(Find.ById("submit")).Click();
    ieStaticInstanceHelper.IE.Close();

在 Dev10(Visual Studio 10) 中右键单击项目并选择 [测试][NUnit 2.5],此测试代码运行没有问题。我已经安装了测试驱动。 从 C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0\nunit.exe" 打开 NUnit 并然后打开我的测试 dll 时,NUnit 错误和失败中会报告以下文本

... LoginAsWellKnownUserShouldSucceed:
System.Runtime.InteropServices.COMException : Error HRESULT E_FAIL has been returned from a call to a COM component.

作为旁白。 .. 右键单击​​ Dev10 中的源 cs 文件并选择运行测试,... 也可以。 上面的测试实际上是TechTalk.SpecFlow 1.3步骤的一部分,我安装了NUnit 2.5.5.10112,安装了Watin 20.20, 我的测试 dll 有以下 App.config
开始尖括号已被删除...如何让 xml 显示在“

configuration>
  configSections>
    sectionGroup name="NUnit">
      section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
    /sectionGroup>
  /configSections>
  NUnit>
    TestRunner>
      add key="ApartmentState" value="STA" />
    /TestRunner>
  /NUnit>
  appSettings>
    add key="configCheck" value="12345" />
  /appSettings>
/configuration>

之前有人打过这个”中吗? NUnit 测试显然在 TestDriven 的 NUnit 2.5.5 中运行,但在从 Dev10 和 TestDriven 外部运行 NUnit 2.5.5 时却不能运行?

I have the following code in an Nunit test ...

    string url = "";
    url = @"http://localhost/ClientPortalDev/Account/LogOn";
    ieStaticInstanceHelper = new IEStaticInstanceHelper();
    ieStaticInstanceHelper.IE = new IE(url);
    ieStaticInstanceHelper.IE.TextField(Find.ById("UserName")).TypeText("abc");
    ieStaticInstanceHelper.IE.TextField(Find.ById("Password")).TypeText("defg");
    ieStaticInstanceHelper.IE.Button(Find.ById("submit")).Click();
    ieStaticInstanceHelper.IE.Close();

On right-clicking the project in Dev10(visual studio 10) and choosing [Test With][NUnit 2.5], this test code runs with no problems. I have TestDriven installed.
When opening the NUnit from C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0\nunit.exe" and then opening my test dll, the following text is reported in NUnit Errors and failures

... LoginAsWellKnownUserShouldSucceed:
System.Runtime.InteropServices.COMException : Error HRESULT E_FAIL has been returned from a call to a COM component.

As an Aside ... Right-Clicking the source cs file in Dev10 and choosing Run Test, ... works as well.
The above test is actually part of TechTalk.SpecFlow 1.3 step, I have NUnit 2.5.5.10112, installed, I have Watin 20.20 installed,
I have the following App.config for my test dll
the start angle brackets have been removed ... how do you get xml to show up in

configuration>
  configSections>
    sectionGroup name="NUnit">
      section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
    /sectionGroup>
  /configSections>
  NUnit>
    TestRunner>
      add key="ApartmentState" value="STA" />
    /TestRunner>
  /NUnit>
  appSettings>
    add key="configCheck" value="12345" />
  /appSettings>
/configuration>

Anyone hit this before ?
The NUnit test obviously runs in NUnit 2.5.5 of TestDriven but not when running NUnit 2.5.5 from outside of Dev10 and TestDriven ?

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

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

发布评论

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

评论(3

旧故 2024-09-09 10:11:38

以管理员身份在 NUnit 中运行测试。
我以管理员身份运行 Dev10,这样我就可以附加和调试 w3ww,这就是 TestDriven 测试有效的原因。
一旦我开始以管理员身份运行 NUnit,COM 服务器问题就消失了。
更令人困惑的是,即使 NUnit 没有以管理员身份运行,从 Watin 站点针对 google 运行 hello-world exmaple 仍然可以工作。
要对本地 Web 服务器使用 NUNit + Watin +,以管理员身份运行 NUnit 可以解决 com 服务器异常问题。

Run the test in NUnit as admin.
I was running Dev10 as admin so I could attatch and debug w3ww, which was why the TestDriven test was working.
As soon as I started running NUnit as admin the COM Server isue issue goess away.
What makes it more confusing is that running the hello-world exmaple against google from the Watin site works even though NUnit is not run as admin.
To use NUNit + Watin + against local web server, running NUnit as admin solves the com server exception issue.

忆悲凉 2024-09-09 10:11:38

尝试在测试代码中使用 RequiresSTA 属性而不是配置文件。

Try using RequiresSTA attribute in your test code instead of the configuration file.

救星 2024-09-09 10:11:38

我正在使用 MSTest,调用 Refresh 以避免缓存数据,这对我有用:

browser.Refresh();
browser.TextField(Find.ById("username")).TypeText("user");
browser.TextField(Find.ById("password")).TypeText("pass");
browser.Button(Find.ByName("SUBMIT")).Click();

I am using MSTest, call Refresh to avoid cached data, this worked for me:

browser.Refresh();
browser.TextField(Find.ById("username")).TypeText("user");
browser.TextField(Find.ById("password")).TypeText("pass");
browser.Button(Find.ByName("SUBMIT")).Click();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文