28

Tarun Lalwani - Best Practices for Your HP BPT Framework

Embed Size (px)

DESCRIPTION

Presented at the HP Discover 2011 on topic - "Best Practices for your HP BPT Framework". The presentation covers few aspects of working with BPT and some new innovative thoughts to improve performance and maintainability.The speaker Tarun Lalwani is author to the best selling QTP book - "QuickTest Professional Unplugged". The book was recognized as the Best Automation book in the 2nd ATI Automation Honors award

Citation preview

Page 1: Tarun Lalwani - Best Practices for Your HP BPT Framework
Page 2: Tarun Lalwani - Best Practices for Your HP BPT Framework

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

BEST PRACTICES FOR YOUR HP BUSINESS PROCESS TESTING FRAMEWORK - Doing it the right way

Tarun Lalwani

Page 3: Tarun Lalwani - Best Practices for Your HP BPT Framework

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

ABOUT THE SPEAKER- Tarun Lalwani

Page 4: Tarun Lalwani - Best Practices for Your HP BPT Framework

About the Speaker – Tarun Lalwani

4 Best Practices for your BPT Framework

• 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

Page 5: Tarun Lalwani - Best Practices for Your HP BPT Framework

BUSINESS PROCESS TESTING

Page 6: Tarun Lalwani - Best Practices for Your HP BPT Framework

Scenario – Create and Approve User

6 Best Practices for your BPT Framework

• Consider steps for a user creation and approval scenario– Launch the application

– Login using customer care user id

– Create a new user

– Logout and close the application

– Launch the application

– Login using admin user id

– Approve the new user

– Logout and close the application

Page 7: Tarun Lalwani - Best Practices for Your HP BPT Framework

Typical BPT Design for the Scenario

7 Best Practices for your BPT Framework

• Create re-usable components– Launch Application

– Login

– Create User

– Approve User

– Logout

– Close Application

Page 8: Tarun Lalwani - Best Practices for Your HP BPT Framework

Facts About the Design

8 Best Practices for your BPT Framework

• Created 6 reusable components

• Easy to use and remember

• 10 components called in the Business Process Test

• High reusability

Page 9: Tarun Lalwani - Best Practices for Your HP BPT Framework

OPTIMIZING SCRIPTS

Page 10: Tarun Lalwani - Best Practices for Your HP BPT Framework

Optimizing Scripts

10 Best Practices for your BPT Framework

• 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 scripted components with more flexibility

Page 11: Tarun Lalwani - Best Practices for Your HP BPT Framework

SMART TAGS

Page 12: Tarun Lalwani - Best Practices for Your HP BPT Framework

Smart Tags

12 Best Practices for your BPT Framework

• 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

Page 13: Tarun Lalwani - Best Practices for Your HP BPT Framework

13 Best Practices for your BPT Framework

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 datatableparameter

Default Smart Tags

Page 14: Tarun Lalwani - Best Practices for Your HP BPT Framework

Smart Tag Sample

14 Best Practices for your BPT Framework

Page 15: Tarun Lalwani - Best Practices for Your HP BPT Framework

Custom Smart Tags

15 Best Practices for your BPT Framework

• 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

Page 16: Tarun Lalwani - Best Practices for Your HP BPT Framework

FLEXIBLE COMPONENTS

16Best Practices for your BPT Framework

Page 17: Tarun Lalwani - Best Practices for Your HP BPT Framework

Flexible Component

17 Best Practices for your BPT Framework

• 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

Page 18: Tarun Lalwani - Best Practices for Your HP BPT Framework

Flexible Component – Perform Launch and Logout

18 Best Practices for your BPT Framework

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

Page 19: Tarun Lalwani - Best Practices for Your HP BPT Framework

Create and Approve User – Flexible Components

19 Best Practices for your BPT Framework

Page 20: Tarun Lalwani - Best Practices for Your HP BPT Framework

20 Best Practices for your BPT Framework

Optimizing Existing BPT Scripts

1 2 3 4Analyze 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

Page 21: Tarun Lalwani - Best Practices for Your HP BPT Framework

Component Merge Recommendation Tool

21 Best Practices for your BPT Framework

• 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

Create User13%

Open User84%

Bad Login3%

Create User

Open User

Bad Login

Component Called After - Login

Page 22: Tarun Lalwani - Best Practices for Your HP BPT Framework

Benefits of Component Merging

22 Best Practices for your BPT Framework

• 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

Page 23: Tarun Lalwani - Best Practices for Your HP BPT Framework

BPT 2 QTP CONVERTER

23Best Practices for your BPT Framework

Page 24: Tarun Lalwani - Best Practices for Your HP 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 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 short-circuiting of parameters

Combines all component code

into single component

Generates a notepad file

Page 25: Tarun Lalwani - Best Practices for Your HP BPT Framework

Converted Code from BPT to QTP Script

25 Best Practices for your BPT Framework

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“)

Page 26: Tarun Lalwani - Best Practices for Your HP BPT Framework

Benefits of Conversion to QTP Script

26 Best Practices for your BPT Framework

• 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

Page 27: Tarun Lalwani - Best Practices for Your HP BPT Framework

THANK YOU

Page 28: Tarun Lalwani - Best Practices for Your HP BPT Framework