Introduction to DataPool in Rational - Continued (2)

zhaozj2021-02-16  50

'$ Include "sqautil.sbh"

Sub

Main

Dim Result As INTEGER

DIM DP_ID AS Long

DIM DP_RESULT AS Long

DIM STRMESSAGE AS STRING

DIM vStext As String

DIM CNN As Object

DIM RST As Object

DIM Strlink As String

DIM STRSQL AS STRING

DIM STRNAME AS STRING

DIM STRPASSWORD AS STRING

'INITIALLY Recorded: 2004-4-24

10:30:51

'Script name: four

Strlink = "Connecting Strings"

SET CNN = CreateObject ("AdoDb.Connection")

Set Rst = CreateObject ("AdoDb.Recordset")

CNN.Open strlink

Rst.cursorlocation = 0

Rst.lockType = 1

Rst.cursortype = 2

ON Error Goto Last

StartApplication "XXX"

Window setContext, "CAPTION = Login", ""

DP_ID = SQADATAPOOLOLOPEN ("DP", False, SQA_DP_SEQUENTIAL, FALSE)

DP_RESULT = SQADATAPOOLFETCH (DP_ID)

IF (DP_RESULT = 0) THEN

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"

StrMessage = "User Name:" Strname "; Password:" Strpassword

strsql = "Select * from login where name =" " strname " "and password =" "" "" ""

Rst.Open Strsql, CNN

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

'This function is as an insert verification point, the verification point is the form prompt information, and does not use Window Image as the verification point because it is not possible to modularize the script, stored in the SHL file, and the multi-platform will be used in the future.

SQAGETPROPERTY "label", "text", vStext 'If the RST.RecordCount returns to 1, this user exists in the database

'Test cases are divided into successful, failed test cases, even if data

'Error, but the expected output is the use case of success, so write to the letter in the Result Report

'Interest is three kinds, success, failure, expected failure, is not expected in the program

'Body, automatically shut down with the program, continue to execute, safe practice to make a sign and then close

'Close the entire software, restart the software, the test script continues from the failed

if Rst.Recordcount = 1 THEN

IF (vStext = "Landing Success") THEN

PushButton Click, "Text = OK"

SqlogMessage SqaPass, "Test Data is" StrMessage "test case execution", "project name"

Else

'There is an abnormal form, the use case test failed

SQALogMessage SQAFAIL, "Test Data is" StrMessage "test case failed", "project name"

SqagetProperty "Window", "Text", vStext

SqlogMessage SQAFAIL, "Error Form:" vStext, "Project Name"

Window Closewin, "CAPTION =" vStext, ""

END IF

Else

IF (vStext = "landing failed") THEN

'Data error, use case failed, software function is normal

PushButton Click, "Text = OK"

SQALogMessage SQAFAIL, "Test data" strmessage "test case failed but software function is normal," Project Name "

Else

'There is an abnormal form, the use case test failed

SQALogMessage SQAFAIL, "Test Data is" StrMessage "test case failed", "project name"

SqagetProperty "Window", "Text", vStext

SqlogMessage SQAFAIL, "Error Form:" vStext, "Project Name"

Window Closewin, "CAPTION =" vStext, ""

END IF

END IF

Wend

DP_RESULT = SQADATAPOOLCLOSE (DP_ID)

Else

SQALOGMESSAGE SQAFAIL, "Data Pool Opening Fail", "Project Name"

END IF

Last:

SQALogMessage SQAFAIL, "Test script is exception, test script execution failed", "project name"

End Sub

to sum up:

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

New Post(0)