数据驱动框架 [英] Data driven framework

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

问题描述

虽然Coded UI支持基于CSV中的数据行重复测试用例;有没有办法在方法级别进行?

Though Coded UI supports repetition of a test case based on data rows in CSV; is there a way to do it at a method level?

例如。许多序列都是数据驱动的。让我们考虑这个样本测试用例包含以下序列 -  

e.g. Many sequences are data driven. Lets consider the this sample test case consisting of the following sequence -- 

1)作为数据输入操作符登录到应用程序

1) Login into application as data entry operator

2)创建客户记录 - 基本详细信息

2) Create a customer record - basic details

3)输入家庭详细信息(2条记录 - 母亲和父亲)

3) Enter family details (2 records - mother and father)

4)提交客户进行验证

4) Submit customer for verification

5)从应用程序注销

6)以验证者身份登录

6) Login as verifier

7)验证客户

我们应该为3位客户这样做。现在,使用Coded UI提供的现有数据驱动方法,是否可以实现这一目标?或者我是否必须编写自己的框架来实现这一目标?

And we are supposed to do this for say 3 customers. Now, using the existing data driven methodology provided by Coded UI, is it possible to achieve this? Or do I have to write my own framework to achieve this?

推荐答案

我曾经创建(在QTP和VS2010中)测试类似给你的。 他们都在为我工作。请看下面是否对您有所帮助:

I used to created (both in QTP and VS2010) tests similar to yours.  They were all working for me. See below if it would help you:

 

在Uimap.cs中,我会创建:

In Uimap.cs, I would create:

1)LoadDataSet(string dataFile){加载测试数据}

1) LoadDataSet(string dataFile) { Load the test data }

2)LaunchTestSite(){启动IE或Firefox到测试站点}

2) LaunchTestSite() { launch IE or Firefox to the test site}

3)public void Login(string uid,string pwd){do logon}

3) public void Login(string uid, string pwd) { do the logon }

4)public void CreatCust(){do basic detail}

4) public void CreatCust() { do the basic detail }

5)public void PopFamDetail(){do fillulate info}

5) public void PopFamDetail() { do the populate info }

6)public void SubForVerif(){do the submit}

6) public void SubForVerif() { do the submit }

7)public void Logout(){do log out}

7) public void Logout() { do the log out}

8)public void VerifyCust()

8) public void VerifyCust()

 

在测试中可能有所帮助:

In test may help:

 

For(i = 0,i< 3,i ++){

For (i = 0, i <3, i++) {

this.uimap.LaunchTestSite();

this.uimap.LaunchTestSite();

this.uimap.LoadTestSet(" theDataFile");

this.uimap.LoadTestSet("theDataFile");

this.uimap.Login(uid_from_theDataFile,pwd_from_theDataFile);

this.uimap.Login(uid_from_theDataFile, pwd_from_theDataFile);

;;;

;;;;

this.uimap.logout();

this.uimap.logout();

this.uimap.Login(uid_from_theDataFile,pwd_from_t heDataFile); //作为验证者

this.uimap.Login(uid_from_theDataFile, pwd_from_theDataFile); // as verifier

this.uimap.VerifyCust();

this.uimap.VerifyCust();

}

 

DataSet可能包含:

DataSet may contains:

uid    ,pwd,  verifierUID,verifierpwd以及填充字段所需的任何数据

uid    , pwd ,  verifierUID, verifierpwd, and whatever data need to populate the field

john1,pdoe,  vJohn1,vdoe,bla .....

john1, pdoe,  vJohn1, vdoe, bla.....

john2,pdoe,  vJohn2,vdoe,bla .....

john2, pdoe,  vJohn2, vdoe, bla.....

john3,pdoe,  vJohn3,vdoe,bla .....

john3, pdoe,  vJohn3, vdoe, bla.....


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

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