Introduction to DataPool in Rational - Continued (1)

zhaozj2021-02-16  60

Step 1: Create a DataPool named DP, if the field name, password is automatically generated, and then inputs the various data in the test case in DP.

Step 2: Recording the function test script, the script is as follows:

Sub

Main

Dim Result As INTEGER

'INITIALLY Recorded: 2004-4-24

10:59:24

'Script name: FIVE

StartApplication "XXX"

Window setContext, "CAPTION = Login", ""

InputKeys "SA"

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

InputKeys "SA"

PushButton Click, "Text = Login"

Window setContext, "CAPTION = login; class = # 32770", ""

PushButton Click, "Text = OK"

End Sub

Step 3: Recycling the DataPool data, performing automation test, the script is as follows

'$ 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 = Login", ""

DP_ID = SQADATAPOOLOLOPEN ("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 = Login"

Window setContext, "CAPTION = login; class = # 32770", ""

PushButton Click, "Text = OK"

Wend

DP_RESULT = SQADATAPOOLCLOSE (DP_ID)

End Sub

Step 4: Join the execution of successful and failed Result information and write to the Result Report, and the necessary amplifies. Optimize scripts. Join Baseline settings (there are two ideas for test baselines, one is file processing, using file type as text file or Excel or Word, read DataPool test data and file content comparison, detection test data exists in the file, of course here The test baseline is not enough, you can customize the rules, gradually improve, one is to read data directly from the database, use the database as Baseline to avoid the addition of test cases, change the Baseline file, of course to test theory No, it should be saved to a specific file to a specific file as Baseline, which is left to you to improve it). The script is as follows:

转载请注明原文地址:https://www.9cbs.com/read-23771.html

New Post(0)