Data-Driven Testing With TestComplete V6.0

Data-driven testing is a very important aspect of test automation. In short, the goal is to run a given test or set of tests multiple times with different sets of input data and expected results.
This means using a single test to verify many different test cases by driving the test with input and expected values from an external data source instead of using the same hard-coded values each time the test runs. This way, we can test how the application handles various inputs without having a numerous similar tests that only have different data sets.
By considering these aspects, Testcomplete includes special program objects that let us easily access data stored in an Excel sheet, CSV file or in a ADO database table. These objects are called drivers. They are typically needed to perform data-driven tests, however, we can also use them to retrieve data from the mentioned storages.
The DDT object is used to create drivers for ADO database tables, Excel sheets and files holding comma-separated data (CSV file). Its methods return special “driver” objects that have access to values stored in the mentioned data storages.

CSV Driver – Is used to read text file such as comma delimited (default) or tab delimited (using a
Schema.ini file).
[Note] By default the first row is the header information (or column names) for the driver.
Excel Driver – Is used to read an Excel spreadsheet. The first row of the sheet is the header
information for the driver.
ADO Driver – Is a generic driver for a database table or record set that can be accessed via Microsoft's ADO DB.

In the example below creates a DDT driver for an ADO DB, runs through records of the driver’s table and retrieve & write values stored in record data source to the Notepad.

Dim MyDriver

Sub Main

'Global Variables

Dim SQLStatement
Dim ConnectionString

' Start Notepad
TestedApps.Notepad.Run

'Assign SQL Statement to Variable
SQLStatement = "SELECT TL_Id, TL_Name From Personnel"

'Set Connection String
ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;" & _
"Persist Security Info=False;" & _
"Initial Catalog=Darshika_TestDB1;Data Source=.\SQLExpress"

'Create Driver
Set MyDriver = DDT.ADODriver(ConnectionString,SQLStatement)

'Call Method
MyDriver.DriveMethod("Main.DDTest1")

End Sub


Sub DDTest1

'Global Variables
Dim p1
Dim w1
Dim w2
Dim KeyStr

'Start & Open Notepad
Set p1 = Sys.Process("Notepad")
Set w1 = p1.Window("Notepad", "*")
Set w2 = w1.Window("Edit")
w2.VScroll.Pos = 0

' Create String with Customer Information
KeyStr = MyDriver.Value("TL_Id")& "," & _
MyDriver.Value("TL_Name")& "," & "[Enter]"
Call w2.Keys( KeyStr)
End Sub

Comments

0 Responses to "Data-Driven Testing With TestComplete V6.0"

Post a Comment