Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

BEST PRACTICES FOR YOUR HP BUSINESS PROCESS TESTING FRAMEWORK

- Doing it the right way

Tarun Lalwani
2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

ABOUT THE SPEAKER


- Tarun Lalwani

2010 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice

About the Speaker Tarun Lalwani


Working with Infosys since 2004 Working on QTP since version 8.2 16000+ Posts on various QTP Forums Author of the first ever book on QTP QuickTest Professional Unplugged Winner of QTP 11 Beta Best Feedback Award Winner of 2nd ATI Automation Honour Awards Expertise in Framework design using QTP, QC and BPT

Best Practices for your BPT Framework

BUSINESS PROCESS TESTING

Scenario Create and Approve User

Consider steps for a user creation and approval scenario


Launch Login

the application

using customer care user id a new user and close the application the application the new user

Create Logout

Launch Login

using admin user id and close the application

Approve Logout

Best Practices for your BPT Framework

Typical BPT Design for the Scenario

Create re-usable components


Launch Application Login Create

User User

Approve Logout

Close Application

Best Practices for your BPT Framework

Facts About the Design


Created 6 reusable components Easy to use and remember 10 components called in the Business Process Test High reusability

Best Practices for your BPT Framework

OPTIMIZING SCRIPTS

Optimizing Scripts

Scripts can be optimized in different ways


Reducing Reducing Reducing Creating

unnecessary parameters (run-time or hardcoded) test data needs using concepts of Smart Tags # of components required to implement scripts

scripted components with more flexibility

10

Best Practices for your BPT Framework

SMART TAGS

Smart Tags

Smart Tags are special tags used for data generation Developed at Infosys, not provided by the default BPT framework Allow creating dynamic data at run-time Eliminates the need to update input data in certain scenarios Parsed and converted to actual value by component Can be combined with static text Multiple Tags can be used for the same parameter

12

Best Practices for your BPT Framework

Default Smart Tags


Smart Tag #NOW# #RAND[N]# #RANDA[N]# #RANDN[N]# Usage #NOW# - Date and time in just numbers (DDMMYYYYHHMMSS) #NOW[Format]# - Date in specified format #RAND[N]# - N character long random string #RANDN[N]# - N character long random number #RANDA[N]# - N character long random alphanumeric string #NEW# - Select a new value. Used for radio buttons, list, checkboxes #NEW[ValueA, ValueB, ValueC]# - Select a new value present in the list #ENV[NAME]# - Read the value from specified environment variable #PARAM[NAME]# - Read the value from specified component parameter #DATATABLE[NAME]# - Read the value from specified datatable parameter Description Generate the current date and time. Useful for generating unique data records Generates random string and numbers

#NEW#

Select a new value always from the control Read the value from Environment variable Read the value from component parameter Read the value from datatable parameter

#ENV[NAME]# #PARAM[NAME]# #DATATABLE[NAME]#

13

Best Practices for your BPT Framework

Smart Tag Sample

14

Best Practices for your BPT Framework

Custom Smart Tags


Specific to Application Under Test Used to execute flow and capture generated values at run-time Example - #NEWCUSTOMER[Tarun,Lalwani]# generates a new customer with the specified first name and last name

15

Best Practices for your BPT Framework

FLEXIBLE COMPONENTS

Best Practices for your BPT Framework 16

Flexible Component

Instead of building high # of re-usable components build larger flexible components Combine commonly performed actions into a single component Add Boolean flags to control actions to be performed Use functions to perform specific Actions in component Use Scripted component instead of Business component

17

Best Practices for your BPT Framework

Flexible Component Perform Launch and Logout


If IsParameterSet("bLogoutPrevious") Then Call CP_Logout() End If If IsParameterSet("bClosePreviousBrowser") Then Call CP_CloseBrowser() End If If IsParameterSet("bLaunchApplication") Then Call CP_LaunchApplication() End if If IsParameterSet("bLogin") Then Call CP_Login() End if
18 Best Practices for your BPT Framework

Create and Approve User Flexible Components

19

Best Practices for your BPT Framework

Optimizing Existing BPT Scripts


1

Analyze

Merge

Unit Test

Update Script

Analyze existing component usage pattern

Merge common component pattern calls

Test the merged component

Update scripts to use the merged component

20

Best Practices for your BPT Framework

Component Merge Recommendation Tool

Developed at Infosys, Tool analyses existing BPT scripts and recommends which components can be merged for optimization Sample Graph recommending merging of Login and Open User (84%) components Bad Login
3% Create User 13% Create User Open User Bad Login Open User 84%

Component Called After - Login


21 Best Practices for your BPT Framework

Benefits of Component Merging


Re-usable components required in the Test suite is reduced The flexibility/re-usability remains similar or even higher Less components required per Business Process Test Reduction in development and maintenance effort Reduction in Execution time

22

Best Practices for your BPT Framework

BPT 2 QTP CONVERTER

Best Practices for your BPT Framework 23

BPT 2 QTP Converter


Developed at Infosys, Tool to convert BPT Scripts to a Single QTP Script BPT2QTP.QFL to be added to the converted script to support the changes Resolves output to input short-circuiting of parameters Ability to fetch run-time parameter values directly from Test Set

Select Scripts to be converted

Download all Components to Local directory

Resolves shortcircuiting of parameters

Combines all component code into single component

Generates a notepad file

Converted Code from BPT to QTP Script


bLoadSession = False Dim Parameter, LocalParam 'Code for Business Component - Perform Launch or Logout ExecuteGlobal StartComponent("Perform Launch or Logout") 'Parameters for the Business Component - Perform Launch or Logout Parameter("bLogoutPrevious") = "FALSE" .. Call EndComponent("Perform Launch or Logout") 'Code for Business Component - Create User 'Parameters for the Business Component - Create User . Call EndComponent("Create User)

25

Best Practices for your BPT Framework

Benefits of Conversion to QTP Script


Faster execution of scripts (20% - 50% faster) Easy to debug scripts Capability to resume scripts from any component, remembers the run-time parameter values of last run using external XML file

26

Best Practices for your BPT Framework

THANK YOU

You might also like