Create a Custom Java Filter
This task describes how to create a custom Java filter. For background information, see Java Custom Filters Overview.
For details of the hook file structure, see Hook File Structure.
When preparing a script, you may need to customize the filter several times in order to achieve the optimal filter. An optimal filter records the relevant methods without introducing a large number of irrelevant calls to the script.
Note: If you plan to add manual code to your script such as control flow or message statements, make sure to do so after you have a functional script that runs inside VuGen. The reason for this, is that if you re-record a script after modifying the filters, it will overwrite all manual changes.
Define a Custom Hook File
Create a user.hooks file in the VuGen installation classes folder, typically C:\Program Files (x86)\HPE\Virtual User Generator\classes. VuGen automatically searches for this file when recording. For structural details about the user.hook file, see Hook File Structure.
Open the Recording Options dialog box (Ctrl+F7) and select the Log Options node. Select the Log Level to Detailed.
Record your application. Click Start Record (Ctrl + R) to begin and Stop (Ctrl + F5) to end.
View the script's steps. If you can determine the business logic from the steps and apply correlation, you may not need to create custom filters. If, however, the script is very long or hard to maintain and correlate, you should customize the script's filter.
Try to identify the high-level method in the call that captures or wraps one or more client server calls. You can do this by opening the AUT source files (if they are available) or by viewing a Stack Trace of the script.
Set the filter to include the relevant methods. For more information, see Java Custom Filters - Determining which Elements to Include.
Record the application again. You should always rerecord the application after modifying the filter.
Repeat steps 4 through 7 until you get a simple script which can be maintained and correlated.
Correlate the script. In order for your test to run properly, you may need to insert a correlation to capture a value and use it at a later point in the script. For more information about the built-in correlation mechanism, see Java Scripts Correlation - Serialization.
Note: Do not modify any of the other .hooks file as it might damage the VuGen recorder.
Adding custom hooks to the default recorder is a complicated task and should be considered thoroughly as it has both functional and performance consequences.
Caution: Incorrect hooking definitions can lead to incorrect scripts, slow recording, and application freeze-up.