How to add database checkpoints in qtp

Source: Internet
Author: User

1. How to generate or modify SQL statements
Use Insert-> checkpoint-databasecheckpoint to generate a database checkpoint. During the generation process, you must set a query statement and obtain a query result table based on the query statement, the data in this table is the expected data. In the future, when running the script, qtp obtains actual data from the current database based on the query statement, and then compares the actual data with the expected data to determine whether the checkpoint is successful.

2. Modify query results

After the checkpoint statement is generated, A dbtable object is generated. This object is displayed in the keyword view and also exists in the repository. You can modify the SQL statement by setting the object properties attribute "Source" of the dbtable object. If the SQL statement is modified, the query result is modified.

After an SQL statement is modified, the expected data table cannot be modified accordingly.

3. How to understand the checkpoint Properties)

The preceding table is truncated when a Check Point is created. (No matter when the attribute window is opened, the data in the table will not change, but you can manually modify the data in the table through "Configure value-> constant" in the window, after modifying the data in this way, it is equivalent to modifying the data. If the cell data is parameterized through "Configure value-> parameter", although it seems that the data is modified, if you select constant again, the data will be restored, therefore, using parameterized data does not affect the data .)

4. Specify the region to be checked

Specify the region to be checked in the table. (The displayed value in the region is the expected value. The expected value can be a constant or a parameter variable.

When setting column by position on the cell identification page, the columns in this table must correspond to the columns in the actual query table; otherwise, the check fails. For example, when the checkpoint name is generated, the query statement is "select username, ID, realname from sys_user t". Then, by modifying the object properties, the query statement is changed to "select username, realname, ID from sys_user T ", The check will fail because the data in columns 2nd and 3 in the query table cannot match the truncated table. Similarly, if you set row by rownumber on the cell identification page, the same problem also exists .)

The following are the three tabs in the property box:

(1) expected data-set the expected value, which can be a constant or a parameter. For example, qtp can be used as the expected value from data table.

(2) settings-set the syntax rules when the expected value is compared with the actual value.

(3) cell identification-guides qtp to place inspected data. For example, if you want to check the data in Column 2nd of the first row in the Check Point attribute box, you understand that the sorting of the queried data rows may change every time you run the test script. Therefore, let qtp locate cells through column names and row containing a known value in akey column, instead of locating cells through the number of columns or number of rows.

5. Checkpoint attribute window:

Checkpoint timeout-specifies the maximum time limit for the checkpoint to run. qtp performs the next operation only after the checkpoint passes (within this time range) or times out. If the check has not passed during the maximum time, this check fails.

For example, it takes a certain amount of time for the checkpoint to load data, increasing the checkpoint timeout time. This ensures that the checkpoint has enough time to pass the check and will not time out and fail.

Note: The checkpoint timeout option is only valid for the table checkpoint and invalid for the database checkpoint.

Insert statement-when a Check Point is added, it specifies the position where the checkpoint statement is inserted in the script.

Note: The insert statement option is invalid when recording or modifying check points. It is only valid when new check points are added.

Note: When a column is a key column, it is not necessarily the column to be checked. The data of the key column is only used to determine the data row to be checked.

6. Comparison rules of specified data
This setting determines how the real data unit compares with the expected data. This setting is valid for all cells.

By default, the actual data unit is considered to be a string type and is precisely checked, but spaces are ignored.
(1) Verification type
Specifies how the content in a cell is compared.

String content-default. The checked data will be treated as strings. For example, 2 and 2.00 are considered different values.

Numeric content-the checked data is treated as a numerical value. For example, 2 and 2.00 are considered to be the same value.

Numeric range-as long as the data satisfies a certain range, it will pass the check. The actual data only needs to be between the minimum and maximum values.
(2) exact match
Default value. Exact match. If this option is selected, exact match is performed. If this option is not selected, the expected value is included in the actual value.

Note: This option is displayed only when verirication type is string content.
(3) Ignore Space
Default value. Ignore spaces in cells during comparison. Adding or removing spaces does not affect the check results.

Note: This option is displayed only when verirication type is string content.
(4) match case
It is case sensitive to letters.

Note: This option is displayed only when verirication type is string content.
(5) min/MAX
Specifies the error range of the data. As long as the data is within the error range, it can be regarded as correct data.

Note: This option is displayed only when verirication type is Numeric range.

7. Specify cell identification settings

The settings in the cell identification tab are used to determine how qtp locates the data unit corresponding to the expected value in the actual data table.

The cell identification tab includes the following options:

(1) Identify Columns
Specifies the column position of the actual data unit to be compared with the expected data in the actual data table.

By position-locate by column sequence (that is, the nth column in the expected data table corresponds to the nth column in the actual data table ). If the column position produces a displacement, it will cause a mismatch. This option is generally used for table checkpoints.

By Column name-locate by column name (that is, the column name in the expected data table corresponds to the column name in the actual data table ). Column displacement does not affect the checkpoint. It is generally used for database checkpoints and is invalid for table checkpoints.
 
(2) identify rows
Specifies the row location of the actual data unit to be compared with the expected data in the actual data table.

By row number-default. Location Based on the order of rows (that is, the nth row in the expected data table corresponds to the nth row in the actual data table ). If the row is displaced, it will cause a mismatch.

By selected key column (S)-after this item is selected, you can set the key column, with a "key" mark next to the key column name. When locating a row, find the value that matches the value of the key column in the expected data table in the key column of the actual data table. The 1st matching values are correct rows. The sequential displacement of rows does not affect the check results. If multiple rows in the database meet the conditions at the same time, qtp checks only 1st records. The key value can be the Union value of multiple columns.
 
(3) Use Value match criteria to identify data in the key column
When matching key columns, use the matching rules set in the verification type option of the Setting tab.

Note: This option is valid only when the by selected key column (s) option is selected.

When the by row number option is selected, the number of rows with the expected value in the attribute window should be the same as the number of rows with the actual data; otherwise, the matching fails. Therefore, row shifting will cause the check to fail.

When select by selected key column (s), the expected value in the attribute window can be in any row position. During the check, the key column value of the row is used as the condition for filtering in the database. If a qualified record is selected, the record is compared with the expected value, if all the recorded data matches, the check is successful. (When multiple key column columns exist, the filtering condition is the combination of the data of these columns ).

Pay attention to the following issues:

(1) only checked data is checked. It does not matter if the other data is not checked, even if it does not match.

(2) If the data in the key column is not checked, it will not be checked. It only provides query conditions.

(3) the data in the attribute window data table itself is the default expected data. Of course, you can modify the expected data.

(4) the data in the data table in the attribute window is relatively fixed, unless you have made any special changes in this attribute window.

(5) The data displayed in the data table in this attribute window is expected data, and the real data table is invisible. Real Data Tables may be different during each script execution.

(6) In the running result, if the check fails, you can click "Checkpoint 'table name' to view the check result table. Double-click a cell in the table. The displayed window displays the expected and actual values of the cell. Of course, the expected values are displayed in this result table.

(7) If a checkpoint data is set in the data table in the attribute window, but the database contains multiple data that meets the conditions, only the first data that meets the conditions is checked, if the first check matches exactly, the request passes. If the check does not match, the request fails.

(8) If multiple identical checkpoint data entries are set in the data table in the attribute window, but only one data entry in the database meets the conditions, this data record is matched with only 1st checkpoints. Other checkpoints fail.

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/Alinaxz/archive/2010/01/05/5134564.aspx

 

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/Alinaxz/archive/2010/01/05/5134564.aspx

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/Alinaxz/archive/2010/01/05/5134564.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.