You are on page 1of 14

Advanced QTP:

Database Checkpoint
Database checkpoint

Database Checkpoint : Agenda


• Concept of database checkpoint
• Creating a database checkpoint
• Some Important concepts
– Difference between identifying rows as “By row number” and “By selected
key column(s)”.
– Parameterize the database checkpoint.
• Database checkpoint created programmatically
• Case Study: Checking the validity of a user name using
database checkpoint.

Accenture Confidential. For Internal use Only. 2


Database checkpoint

Concept of Database Checkpoint


• Database Checkpoint checks the contents of a database
accessed by the application.

• We compare the actual data in database with the expected


data which we set while creating a checkpoint
– For example, a person books a flight ticket in the Mercury Tours website. A
booking id is generated at runtime which is unique and which is one more
than the booking id generated for last user. We create a database
checkpoint which validates that the correct id has been generated

Note:
We set the expected data in the Database Checkpoint Properties dialog box.

Accenture Confidential. For Internal use Only. 3


Database checkpoint

Creating a Database Checkpoint


• The checkpoint can be inserted by going to the following
options -
Insert --> Checkpoint --> Database Checkpoint
• Then we can specify the SQL query for accessing data
using Database query wizard.

Accenture Confidential. For Internal use Only. 4


Database checkpoint

Creating a Database Checkpoint – contd..


• The query can be specified manually or using Microsoft
Query.

• The results of the query is the displayed in the Database


Checkpoint properties window.
Note:
Incase we choose to create the query using MS query and select the option a pop up window
comes which guides us on how to use the MS query tool to specify the query. This is possible
if we have checked the “Show me how to use MS Query” option in Database Query wizard.

Accenture Confidential. For Internal use Only. 5


Database checkpoint

Creating a Database Checkpoint – contd…


• The Database Checkpoint properties window represents
the expected data,
• The expected value can be configured by selecting it in the
table and changing it in the Configure value box

Accenture Confidential. For Internal use Only. 6


Database checkpoint

Creating a Database Checkpoint – contd…


• If we require to make a particular variable as a key value
check “By selected key column(s)” in Cell Identification tab
and select the required column from the list.
• Depending on where we require the DB checkpoint, the
insert statement can be checked as “Before current step”
or “After current step”

Accenture Confidential. For Internal use Only. 7


Database checkpoint

Creating a Database Checkpoint – contd…


• The database checkpoint is inserted in the keyword view
and is represented as shown below –

In expert view it is represented by the following VBscript


code -
DbTable("DbTable_4").Check CheckPoint("DbTable_4")

Note:
For the Mtours Flights example the mercurytours datasource is used

Accenture Confidential. For Internal use Only. 8


Database checkpoint

Some Important concepts


• Difference between identifying rows as “By row number”
and “By selected key column(s)”.
– When row option is “By row number”, the tool matches the expected
values and actual database values on a one to one basis i.e. value
found based on row and column matches.
– When row option is “By selected key column(s)” the expected and
actual data values are matched irrespective of the order in which they
appear.

e.g. say the expected data for User name is-


1. Amit
2. Abc
while the database User name column has values as –
1. Abc
2. Amit
In case we create a database checkpoint for User name and we have the
option as “By row number “ and run the test the checkpoint fails however if
we have option as “By selected key column(s)” the checkpoint is passed.

Accenture Confidential. For Internal use Only. 9


Database checkpoint

Some Important concepts- contd…


• Parameterize the database checkpoint.
– We can instruct QuickTest to use a value from the Data Table as the
expected value for a particular cell.
– Parameterising allows for iterations to be done. In the screen shot shown
below we see the value in cell (1,1) has been parameterized.

Note:
The parameterized checkpoint fails when the
value passed as a parameter appears
before the row which has been
parameterized in the actual table

Accenture Confidential. For Internal use Only. 10


Database checkpoint

Database checkpoint using VB scipt


We can simulate a database checkpoint using VB script.
This will require the use of ADO methods. By using the
methods we can connect and access the database.

Accenture Confidential. For Internal use Only. 11


Database checkpoint

Case Study
• Aim: To validate the user id entered initially.
– We should see to it that if the user id is valid and exists in the database. If it
exists the test goes to completion and the user can book a ticket else the
test fails.
– The case study needs to be implemented using the Wizard as well as using
VB script.

Hints:
– While implementing using the wizard Parameterize the checkpoint
– While using VB script use CreateObject method (ADO methods).
Additionally to display events use  Reporter.ReportEvent method

Accenture Confidential. For Internal use Only. 12


Database checkpoint

Questions?

Q & A….

Accenture Confidential. For Internal use Only. 13


Database checkpoint

Session Wrap-up
• We use database checkpoints to check databases
accessed by your application and to detect defects.
• There are two ways to define a database query:
– Use Microsoft Query.
– Manually define an SQL statement.
• The checkpoint can be parameterized
• The match between the actual value and expected value
can be based on row column match (position taken into
consideration) or based only on values irrespective of
position.
• The checkpoint can easily be created using the wizard, but
another option would be to do the same using VB script

Accenture Confidential. For Internal use Only. 14

You might also like