2010-05-18 35 views
3

我的代码如下NUnit测试...NUnit使用WatiN进行测试,从Dev10运行正常,但是当NUnit从“C: Program Files(x86) NUnit 2.5.5 bin net-2.0 nunit.exe”启动时

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项目(视觉工作室10),选择[测试用] [NUnit的2.5],这个测试代码,没有任何问题上运行。我安装了TestDriven。 当从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. 

Aside Aside ...右键单击Dev10中的源代码cs文件并选择Run Test,运行测试... 上述测试实际上是TechTalk.SpecFlow 1.3步骤的一部分,我有NUnit 2.5。 5.10112,安装,我已经安装了华廷20.20, 我有以下App.config中为我的测试DLL
开始尖括号已被删除...你如何获得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时不会运行?

+0

嗯...是什么DEV10? – 2010-05-18 12:12:55

+0

Dev10 = VisualStudio10;我仍在努力通过这一个; TestDriven使用nunit-x86而不是nunit.exe;也玩删除所有的IE插件;也玩弄了用于watin的IE,我认为这是真正的问题 - 这是非常...不可靠的... ... – user206890 2010-05-19 20:34:59

回答

1

以管理员身份在NUnit中运行测试。 我以管理员身份运行Dev10,因此我可以对w3ww进行协调和调试,这就是为什么TestDriven测试正在进行。 一旦我开始以管理员身份运行NUnit,COM服务器问题就消失了。 更令人困惑的是,即使NUnit没有以管理员身份运行,运行来自Watin网站的hello-world exmaple反对谷歌。
要对本地Web服务器使用NUNit + Watin +,以admin身份运行NUnit可解决com服务器异常问题。

+0

+1作为管理员运行时也为我工作,当自动化IE作为我的NUnit测试的一部分。 – 2011-01-27 01:05:16

0

我使用MSTest的,叫刷新避免缓存数据,这个工作对我来说:

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