Rational中DataPool的介绍与实际应用-续(1)

发表于:2008-09-23来源:作者:点击数: 标签:rationalRationalRATIONAL应用DataPool
第一步:创建名字为dp的 datapool ,假如字段name,password并自动生成数据,然后把 测试 用例 中各种数据输入dp中 第二步:录制 功能测试 脚本,脚本如下: Sub Main Dim Result As Integer 'Initially Recorded: 2004-4-24 10:59:24 'Script Name: Five Star

第一步:创建名字为dp的datapool,假如字段name,password并自动生成数据,然后把测试用例中各种数据输入dp中

第二步:录制功能测试脚本,脚本如下:

 

Sub Main

    Dim Result As Integer

 

    'Initially Recorded: 2004-4-24  10:59:24

    'Script Name: Five

    StartApplication "xxx"

   

    Window SetContext, "Caption=登陆", ""

    InputKeys "sa"

    EditBox Click, "ObjectIndex=1", "Coords=34,9"

    InputKeys "sa"

    PushButton Click, "Text=登陆"

   

    Window SetContext, "Caption=登陆;Class=#32770", ""

    PushButton Click, "Text=确定"

   

End Sub

 

第三步:循环读出datapool数据,进行自动化测试,脚本如下

 '$Include "sqautil.sbh"

 

Sub Main

    Dim Result As Integer

    Dim dp_id as Long

    Dim dp_Result as Long

   

    Dim strName as String

    Dim strPassWord as String

  

    'Initially Recorded: 2004-4-24  10:30:51

    'Script Name: Four

 

    StartApplication "xxx"

    Window SetContext, "Caption=登陆", ""

    dp_id = SQADatapoolOpen ("dp", FALSE, SQA_DP_SEQUENTIAL, FALSE)

   

dp_Result = SQADatapoolFetch (dp_id)

   

     while dp_Result <>  sqaDpEOF

   

           dp_Result = SQADatapoolValue (dp_id, "name", strName)

           dp_Result = SQADatapoolValue (dp_id, "password", strPassWord)

           dp_Result = SQADatapoolFetch (dp_id)

         

           InputKeys strName

           EditBox Click, "ObjectIndex=1", "Coords=34,9"

           InputKeys strPassWord

           PushButton Click, "Text=登陆"

   

           Window SetContext, "Caption=登陆;Class=#32770", ""

           PushButton Click, "Text=确定"

    wend

 

    dp_Result = SQADatapoolClose (dp_id)

   

End Sub

 

原文转自:http://www.ltesting.net