HP Quick Test Professional is a test automation tool, also known as QTP. It is used to automate functional, regression and smoke test cases. It is a very popular software testing tool and works on MS windows O/S, supports development technologies like Active X, Delphi, Java, .Net, Oracle, People Soft, Web services etc. This article presents some best practices while doing automation using QTP.

Author: Abhay Bharti, http://automation.lifegoeasy.com/

Don’t use msgbox function, this function pauses the script execution and requires user intervention. This defeats the objective of unattended script execution. To store or display error message and execution log, use QTP inbuilt Reporter object. Follow coding guidelines like comments, variable and function name declaration. Use option explicit to enforce variable declaration. Always define variables at the top of script and function files. Neither hard code test data nor read value using custom function like Inputbox. Use parameterization to enhance the reusability of the code. QTP provides inbuilt support for Microsoft excel files, store test data in excel file, import excel sheet in QTP DataTable, read value using “DataTable.value” function In large tests, define reusable codes as function in external .vbs file. It consumes less memory than QTP Action. QTP is a hardware hungry application, so your machine should be hardware rich. Use synchronization (like exist, sync etc.) to mitigate timing issue between script and Application under test. Don’t use wait (10) statement. Don’t increase global synchronization time out value; it slows down QTP execution speed. The ideal solution is to implement synchronization at object level not at global level. Create reusable function instead of reusable action; minimize number of actions in a test. Ideally, a test should not contain more than few actions. An action takes more time to load and run. Its limited use improves the execution speed. Be tactful in using QTP features like Descriptive Programming or Object Repository or mixed approach. Each approach has its own advantages and disadvantages. Try to use mix of both. Don’t use inbuilt feature like “Save still image capture to results” and “Save movie to results”. These options decrease QTP run time performance. If required, use VB Script code to take screenshot of script failures. User relative paths while calling library file, reusable action or data files. This makes script portable and easier to manage. Don’t overuse recovery scenario, as it slows down script execution time Do not load unnecessary Add-ins. When QTP starts, it shows list of add-in available, select only required add-in. This will improve performance while learning objects and during run sessions. Run your tests in “Fast mode”. From the Run pane in the Options dialog box, select the Fast option. This enables QuickTest to run test faster. Hide Active Screen. If you are not using the Active Screen while editing your test, hide the Active Screen while editing your test to improve editing response time. Save the test results report to a temporary folder to overwrite the results from the previous run session every time you run a test.

Further reading

Orasi HP QuickTest Professional Best Practices Document (pdf)

Tips to improve QTP script Performance (pdf)

About the Author

Abhay Bharti is a tech blogger and Test Automation Lead. He has 7+ years of working experience in QA domain. He has worked on various test automation projects, using technologies such as VBScript, Excel, HP QTP, Selenium, Java, Eclipse. He is continuously researching to find better ways of working with QTP, simplifying automation maintenance and creating test suites/frameworks.