Você está na página 1de 15

Best Practices with QTP

Summary
Best Practices with QTP Object Repositories Scripting: Modular Scripting, Reusable Actions and Function Libraries Error and Exception Handling Capturing and Analysis of Results Test data preparation

Best Practices with Object Repository

Best Practices : Object Repository


Create a base line object repository with most of the

common objects used across the application. Newly identified objects to be added into the baseline object repository while creating the script Rename objects to meaningful as per the standards Usage of object Identification if any ambiguity to identify the objects. Usage of virtual objects as a last resort if objects are not identified by available mechanism. Create one shared object per high level application module. Maintaining of objects in single browser and multiple pages hierarchy for easy maintenance.

Best Practices with Scripting

Best Practices : Scripting:-Modular Scripting, Reusable Actions and Function Libraries


Design frame work with easy accessible structure. Use Reusable Actions Use Modular Scripting for utmost reusability. Use common library functions and application specific functions for easy maintenance. Create functions locally which are specific to the current script. Place globally used functions in a library external to the script. Only use the Data Table for data that will vary during each test case Use more functions even if it is a single line of code. Minimize the maintenance by reducing the redundancy. Avoid wait statement for synchronization mechanism. Avoid hardcoded values in the script and keep data in external source. Maintenance of header , change history at the file level. Usage of appropriate comments in the files for better understandability and readability. Usage of Environment/ External variables for usage across the scripts.

Record and Run Settings


Use the Record on any open Browser option for

Web Applications. Use the Record on any open Application for Desktop Applications. Avoid recording of actions / flows.

General Test Settings


Most test settings will be defaulted to acceptable

values so that you can start writing your scripts without change to these settings Add the test settings as needed while recording and customizing the scripts(resources, parameters , recovery scenarios, etc) Include only required add ins for creation and execution of scripts.

Descriptive Programming
Use when the properties of an object are dynamic

and its properties are unknown for each iterating of the script Use descriptive programming sparingly. Use descriptive programming to handle multiple browser scenarios.

Best Practices with Error and Exception Handling

Best Practices: Error and Exception Handling


Limit use of Recovery Scenarios to unexpected

errors.

Do not use recovery scenarios when the error messages are predictable Use conditional logic for predictable errors Makes script execution more reliable Use recovery scenarios only if any error occurs.

Best Practices with Capturing and Analysis of Test Results

Best Practices: Capturing and Analysis of Test Results


Usage of Customized Result Template.

Results capturing should be meaningful


Should capture only relevant results for the given

scenario Capturing of important data for failure scenarios. Avoid logging of multiple failure messages. Use screen shots only for failure scenarios. Results should be readable and useful

Best Practices with Test Data Preparation and Verification

Best Practices: Test data Preparation and Verification


Test Case data template should be understandable. Data in the test case should be readable and understandable Avoid redundancy of test data. Columns used in the data sheets should be relevant to

application objects. Test data should be understandable in the relevance to the test case. Usage of date functions in the data sheets for date test case scenarios. Using data output values in the data sheets for inaccessible applications. Using data base connection to verify required data.

Você também pode gostar