数据驱动测试 [英] Data-Driven Testing

查看:112
本文介绍了数据驱动测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照以下链接中提到的程序进行了数据驱动的编码UI测试。

I ttried to do the Data-Driven Coded UI Test by following the procedure mentioned in the below link.

http://blogs.msdn.com /b/mathew_aniyan/archive/2009/03/17/data-driving-coded-ui-tests.aspx

我收到一条错误消息,指出"错误  1 当前上下文中不存在名称"WinProperties"  C:\ Documents / Settings \Test \ My Documents \ Visual Studio 2010 \Projects\Cal_Add \ CodebeITest.cs  30  88  Cal_Add"。

I got an error message saying that "Error 1 The name 'WinProperties' does not exist in the current context C:\Documents and Settings\Test\My Documents\Visual Studio 2010\Projects\Cal_Add\CodedUITest.cs 30 88 Cal_Add".

请告诉我解决方法。您能否详细解释以下代码行:

Please let me know the resolution. And could you please explain in detail about the below code line:

 

 

。UIMap.UICalculatorWindow.UIItem5Window。 UIItem5Button.SearchProperties [WinProperties.PropertyNames.Name] = TestContext.DataRow [ "Add1" ]。ToString();

.UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties[WinProperties.PropertyNames.Name] = TestContext.DataRow["Add1"].ToString();

 

 

 

详细生成/修改后的代码如下:

The Detailed generated/modified code is as below:

使用

 

 

系统;

使用

 

 

System.Collections.Generic;

使用

 

 

System.Text.RegularExpressions;

使用

 

 

System.Windows.Input;

使用

 

 

System.Windows.Forms;

使用

 

 

System.Drawing;

使用

 

 

Microsoft.VisualStudio.TestTools.UITesting;

使用

 

 

Microsoft.VisualStudio.TestTools.UnitTesting;

使用

 

 

Microsoft.VisualStudio.TestTools.UITest.Extension;

使用

 

 

键盘
= Microsoft.VisualStudio.TestTools.UITesting。
键盘 ;

Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard;

namespace

namespace

 

 

Cal_Add

Cal_Add

{

 

 

///
< summary>

 

 

///
CodedUITest的摘要说明

/// Summary description for CodedUITest

 

 

///
< / summary>

[

 

CodedUITest ]

CodedUITest]

 

 

public
class
CodedUITest

{

 

 

public
CodedUITest()

public CodedUITest()

{

}

[

 

DataSource " Microsoft.VisualStudio.TestTools .DataSource.CSV"
" | DataDirectory | \\Testdata.CSV"
" Testdata#CSV"
DataAccessMethod 。Sequential),
DeploymentItem " Testdata.CSV" ),
TestMethod ]

DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Testdata.CSV", "Testdata#CSV", DataAccessMethod.Sequential), DeploymentItem("Testdata.CSV"), TestMethod]

 

 

public
void
CodedUITestMethod1()

public void CodedUITestMethod1()

{

 

 

//要为此测试生成代码,请从快捷菜单中选择"生成
Code for Coded UI Test"代码,然后选择其中一个菜单项。

 

 

//有关生成代码的详细信息,请参阅
http://go.microsoft.com/fwlink/?LinkId=179463

 

 

这个 。UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties [WinProperties.PropertyNames.Name]
= TestContext.DataRow [
"Add1" ]。ToString();

this.UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties[WinProperties.PropertyNames.Name] = TestContext.DataRow["Add1"].ToString();

 

 

这个 。UIMap.UICalculatorWindow.UIItem6Window.UIItem6Button.SearchProperties [WinProperties.Button.Name]
= TestContext.DataRow [
" Add2" ]。ToString();

this.UIMap.UICalculatorWindow.UIItem6Window.UIItem6Button.SearchProperties[WinProperties.Button.Name] = TestContext.DataRow["Add2"].ToString();

 

 

这个 。UIMap.AddMethod();

this.UIMap.AddMethod();

 

  ;

这个 。UIMap.AssertMethodExpectedValues.UIItemEditText
= TestContext.DataRow [
" Sum" ]。ToString();

this.UIMap.AssertMethodExpectedValues.UIItemEditText = TestContext.DataRow["Sum"].ToString();

 

 

这个 。UIMap.AssertMethod();

this.UIMap.AssertMethod();

}

#region

 

 

其他测试属性

// ......

//......

 

 

#endregion

 

 

 

 

 

 

public
TestContext
TestContext

public TestContext TestContext

{

 

 

获取

{

 

 

返回
testContextInstance;

return testContextInstance;

}

 

 

设置

{

testContextInstance =

testContextInstance =

 

value ;

value;

}

}

 

 

private
TestContext
testContextInstance;

private TestContext testContextInstance;

 

 

public
UIMap
UIMap

public UIMap UIMap

{

 

 

获取

{

 

 

if
((
this .map
==
null ))

if ((this.map == null))

{

 

 

这个 .map
=
new
UIMap ();

this.map = new UIMap();

}

 

 

返回
这个 .map;

return this.map;

}

}

 

 

private
UIMap
map;

private UIMap map;

}

}

 

 

请让我知道决议。

谢谢。

推荐答案

<我也遇到了这个问题。该博客文章尚未针对当前的VS2010 RC / RTM版本进行更新。

I had that issue too.  That blog post has not been updated for the current VS2010 RC/RTM build.

 

更改

这个
。UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties [WinProperties.PropertyNames.Name] = TestContext.DataRow [
" Add1"
]。ToString();

这个
。UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties [ WinButton.PropertyNames.Name
] = TestContext.DataRow [
" Add1"
]。ToString();

this .UIMap.UICalculatorWindow.UIItem5Window.UIItem5Button.SearchProperties[WinButton.PropertyNames.Name ] = TestContext.DataRow[ "Add1" ].ToString();

 

和其他类似的类似。

干杯,

Dan


这篇关于数据驱动测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆