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 Award
•
Winner of 2nd ATI Automation Honour Awards
•
Expertise in Framework design using QTP, QC and BPT
4
Best Practices for your BPT Framework
BUSINESS PROCESS TESTING
Scenario – Create and Approve •
Consider steps for a creation and approval scenario – Launch –
the application
using customer care id
– Create
a new
–
and close the application
– Launch
the application
–
using id
– Approve –
6
the new
and close the application
Best Practices for your BPT Framework
Typical BPT Design for the Scenario •
Create re-usable components – Launch Application – – Create
– Approve
– – Close Application
7
Best Practices for your BPT Framework
Facts About the Design •
Created 6 reusable components
•
Easy to use and
•
10 components called in the Business Process Test
•
High reusability
8
Best Practices for your BPT Framework
OPTIMIZING SCRIPTS
Optimizing Scripts •
Scripts can be optimized in different ways – Reducing
unnecessary parameters (run-time or hardcoded)
– Reducing
test data needs using concepts of Smart Tags
– Reducing
# of components required to implement scripts
– Creating
10
scripted components with more flexibility
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
Usage
Description
#NOW#
#NOW# - Date and time in just numbers (DDMMYYYYHHMMSS) #NOW[Format]# - Date in specified format
Generate the current date and time. Useful for generating unique data records
#RAND[N]# #RANDA[N]# #RANDN[N]#
#RAND[N]# - N character long random string #RANDN[N]# - N character long random number #RANDA[N]# - N character long random alphanumeric string
Generates random string and numbers
#NEW#
#NEW# - Select a new value. Used for radio buttons, list, checkboxes #NEW[ValueA, ValueB, ValueC]# - Select a new value present in the list
Select a new value always from the control
#ENV[NAME]#
#ENV[NAME]# - Read the value from specified environment variable
Read the value from Environment variable
#PARAM[NAME]#
#PARAM[NAME]# - Read the value from specified component parameter
Read the value from component parameter
#DATATABLE[NAME]#
#DATATABLE[NAME]# - Read the value from specified datatable parameter
Read the value from datatable parameter
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 16 Practices for your BPT Framework
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 If IsParameterSet("bPrevious") Then Call _() End If If IsParameterSet("bClosePreviousBrowser") Then Call _CloseBrowser() End If If IsParameterSet("bLaunchApplication") Then Call _LaunchApplication() End if If IsParameterSet("b") Then Call _() End if 18
Best Practices for your BPT Framework
Create and Approve – Flexible Components
19
Best Practices for your BPT Framework
Optimizing Existing BPT Scripts 1
Analyze
Analyze existing component usage pattern
20
Best Practices for your BPT Framework
2
Merge
Merge common component pattern calls
3
Unit Test
Test the merged component
4
Update Script
Update scripts to use the merged component
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 and Open (84%) components Bad 3% Create 13% Create Open Bad Open 84%
Component Called After - 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 23 Practices for your BPT Framework
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 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
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 ExecuteGlobal StartComponent("Perform Launch or ") 'Parameters for the Business Component - Perform Launch or Parameter("bPrevious") = "FALSE" ….. Call EndComponent("Perform Launch or ") 'Code for Business Component - Create 'Parameters for the Business Component - Create …. Call EndComponent("Create “)
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, re the run-time parameter values of last run using external XML file
26
Best Practices for your BPT Framework
THANK YOU