Database checkpoints in QTP can be used in the test to check databases accessed by the web site or application and to detect defects. A query can be defined on the database to create a database checkpoint that will check the results of the query.
Ways to define a database query:
- Use Microsoft Query, Microsoft Query can be installed from the custom installation of Microsoft office.
- Manually define an SQL statement.
How To create a Database Checkpoints in QTP:
- Open QTP with a new blank test(From Start Menu ->All Programs->Quick Test Professional(QTP) -> Quick Test Professional
- Select Insert->Checkpoint->Database Checkpoint from the menu of QTP.
- Database query wizard opens up with two options as mentioned below.
Create query using Microsoft Query: Opens Microsoft Query, enabling to create a new query, once the query is defined, return to Quick Test, This option is only available only if it is installed on the computer
- Manually Specify SQL statement: open the specify SQL statement screen in the wizard, which enables to specify the connection string and an SQL statement.
- Click Next to specify the connection string and the SQL statement, Specify SQL statement screen opens up as shown below.
- To make a connection with corresponding database, click “Create…” button.”Select Data Source” dialog box opens up
- Select “Machine Data Source” tab and then select the data source name of the database to be checked or create a new DSN file for the database.
Ex. To Check the database of the Flight Reservation (Application), Select “Flight_32” as Data Source Name(DSN)
- Click “OK” and enter the query to access the database in the “SQL” statement textbox
For Ex. Write the query as “Select * from Orders”
Note: Order is one of the tables of Flight_32 database; Tester can check a database of an application by following methods
- Click on “Finish” to open “Database Checkpoint Properties” where the content of the database is displayed
- Specify checkpoint setting, For ex. Example select “After Current step” option in the insert statement
- Click ok button then QTP adds the script for the database checkpoint in the test script, A tree item with a database checkpoint icon is also added to the test tree, the script looks like as below
- Run the test and get the result, QTP gives the detail about the number of cells in a table, how many succeeded and failed
How To Get a Fail Result
After inserting the database checkpoint in the test script, make changes in the “orders” table of Flight_32 database, then run the script again, the fail result will be displayed
In the result window, QTP will highlight the cell where the expected value is not matched with the actual value, User can see the expected and actual value of a particular cell by double click on the cell as shown below.