Script enhancements are performed on recorded scripts to make them reusable, maintainable, parameterized and correlation enabled. Enhancements ensure that scripts can simulate real user behavior and support different test scenarios and load conditions.
Make Script Reusable
Parameterization, correlation and reusable functions.
Improve Performance
Reduce unnecessary traffic and optimize transactions.
Increase Reliability
Handle dynamic data, avoid errors and test consistently.
Support Scenarios
Data driven scripts for multiple users, scenarios and loads.
Maintainable Scripts
Clean, modular and easy to maintain scripts.
Enhancement Areas (What & Why)
| Area | What We Do | Why We Do It | Example |
|---|---|---|---|
| Parameterization | Replace hard coded values with parameters | Make script data driven and reusable | {userID}, {password} |
| Correlation | Extract dynamic values using rules/regex | Handle dynamic content and maintain session | OrderID, SessionID |
| Think Time | Add realistic delays between user actions | Simulate real user behavior | Random/Fixed think time |
| Transactions | Define transaction start and end points | Measure accurate response time | StartTransaction("Login") |
| Rendezvous / Sync | Synchronize virtual users at specific points | Simulate real world user behavior | rendezvous points |
| Checks / Assertions | Validate server responses and content | Ensure application correctness | Response code, text checks |
| Error Handling | Handle errors and continue or stop | Avoid script failure and better logging | Try/Catch, On Error Continue |
| Modular Functions | Create reusable functions/actions | Improve maintainability | login(), search(), logout() |
| Data Management | Use external data files / DB / Parameters | Handle large data sets efficiently | CSV, Excel, DB, Parameters |
| Logging & Reporting | Add logs for key events and validations | Easier debugging and analysis | LogMessage, Log Status |
Tool Wise Enhancements Overview
LoadRunner
C / C++ based scripting
- Parameterize data using Parameter List.
- Correlate dynamic values using
web_reg_*functions. - Add think time using
lr_think_time(). - Define transactions using
lr_start_transaction()lr_end_transaction(). - Add checks using
web_reg_find(),web_reg_save_param(). - Use custom functions and reusable actions.
- Enhance using vuser_init(), Action(), vuser_end().
- Generate test data using data files / databases.
JMeter
Java based open source tool
- Parameterize using User Defined Variables / CSV Data Set Config.
- Extract dynamic values using Regular Expression Extractor / JSON Extractor / XPath Extractor.
- Add timers (Think Time) – Constant / Uniform / Gaussian Random Timer.
- Add Assertions – Response Assertion, Duration Assertion.
- Use Transaction Controller for transaction.
- Use Pre Processors, Post Processors, Listeners.
- Use Beanshell / JSR223 for advanced logic.
NeoLoad
Scriptless / Coded hybrid approach
- Parameterize using Data Sources (CSV, DB, Excel).
- Correlate using Dynamic Variables & Extractors.
- Add think time using Pacing Profiles.
- Define transactions using Transaction Points.
- Add checks using Verification Points.
- Use scenarios and reusable actions (User Paths).
- Enhance using JavaScript / Custom Code.
- Data management using Data Sources.
Side by Side Comparison
| Enhancement | LoadRunner | JMeter | NeoLoad |
|---|---|---|---|
| Parameterization | Parameter List, lr_eval_string() |
User Defined Variables, CSV Data Set Config | Data Sources (CSV, DB, Excel) |
| Correlation | web_reg_save_param(), web_reg_save_param_ex() |
Regex Extractor, JSON Extractor, XPath Extractor | Extractors, Dynamic Variables |
| Think Time | lr_think_time() |
Timers (Constant, Uniform, Gaussian Random) | Pacing Profiles |
| Transactions | lr_start_transaction(), lr_end_transaction() |
Transaction Controller | Transaction Points |
| Checks / Assertions | web_reg_find(), lr_assert() |
Assertions (Response, Duration, Size) | Verification Points |
| Data Management | Data files (dat), DB, Parameter List | CSV, Excel, DB, Variables | Data Sources (CSV, DB, Excel) |
| Error Handling | On Error Continue, lr_error_message() |
Assertion Results, If Controller, Try Catch | Error Handling Blocks |
| Logging | lr_output_message(), lr_save_string() |
Listeners (View Results, Summary, Logs) | Logs, Monitors, Reports |
Detailed Enhancement Examples
1. Parameterization
Replace hard coded value with parameter.
web_set_header("UserID", "12345");
web_set_header("UserID", lr_eval_string("{UserID}"));
2. Correlation
Extract dynamic value.
web_reg_save_param(
"OrderId",
"LB=<orderId>((^|*))<",
"RB=</orderId>",
LAST);
3. Think Time
Add realistic delay.
lr_think_time(
rand(3, 7)
);
4. Transaction
Measure response time.
lr_start_transaction(
"PlaceOrder");
// steps
lr_end_transaction(
"PlaceOrder",
LR_AUTO);
5. Check / Assertion
Validate response.
web_reg_find(
"Text=Thank you
for your order",
LAST);
Best Practices
- Parameterize all input data.
- Correlate all dynamic values.
- Use realistic think time.
- Create modular and reusable functions.
- Add checks and assertions for validations.
- Use external data sources for large data.
- Log important events and errors.
Common Pitfalls
- Hard coding values in scripts.
- Missing correlation causing script failures.
- Using fixed think time everywhere.
- Improper transaction boundaries.
- Hard coded data in multiple places.
- Ignoring error handling and validations.
Outcome
- Reusable and maintainable scripts.
- Accurate performance results.
- Realistic simulation of user behavior.
- Support multiple scenarios and loads.
- Reduced maintenance effort and time.