Abstract:
The main objective of this paper is to reduce the effort involved in preparing loadrunner scripts using web (http/html) protocol and this is achieved by creating a Function driven framework. Say for example if we have hundreds of scripts with few transactions repeating in each of them, then these repeated transactions are divided into tiny modules or blocks and are converted into user defined functions. These functions will be saved as header files and maintained in a common repository from where they will be called to the loadrunner scripts when they are required. These header files will be modified when there are changes in the requests and we can start the test executions without even opening the other scripts that are using these header files. The major advantages of this framework is preparing and maintaining the scripts will be easier and also it reduces the script debugging and reworking efforts.
Creating a user defined function:
Say for example Login, Home Page & Logout transactions will be common for all the applications. Instead of recording these requests repeatedly for each script, we suggest to record it once and convert it into user defined function and save it in a header file.
What are Header Files?
Header files are used to define all the functions, variables and constants in any function library that we want to use in our C Program. These files instruct the compiler on how to call a function using function names. Declaration of these header files start with #include and end with .h extension.
Below is the script generated in loadrunner for logging into an application (Login Transaction):
Now this App_Launch & App_Login requests have to be converted into a user defined function in a notepad and then save it as “.h” file (i.e.) header file. Similarly, all the repeated actions are converted into header files with user defined functions.
In the below example we have created a function by name “Login()” and we have saved the file as “Login.h”. Maintain these header files in a structured folder path for ease of use.
The main objective of this paper is to reduce the effort involved in preparing loadrunner scripts using web (http/html) protocol and this is achieved by creating a Function driven framework. Say for example if we have hundreds of scripts with few transactions repeating in each of them, then these repeated transactions are divided into tiny modules or blocks and are converted into user defined functions. These functions will be saved as header files and maintained in a common repository from where they will be called to the loadrunner scripts when they are required. These header files will be modified when there are changes in the requests and we can start the test executions without even opening the other scripts that are using these header files. The major advantages of this framework is preparing and maintaining the scripts will be easier and also it reduces the script debugging and reworking efforts.
Creating a user defined function:
Say for example Login, Home Page & Logout transactions will be common for all the applications. Instead of recording these requests repeatedly for each script, we suggest to record it once and convert it into user defined function and save it in a header file.
What are Header Files?
Header files are used to define all the functions, variables and constants in any function library that we want to use in our C Program. These files instruct the compiler on how to call a function using function names. Declaration of these header files start with #include and end with .h extension.
Below is the script generated in loadrunner for logging into an application (Login Transaction):
Now this App_Launch & App_Login requests have to be converted into a user defined function in a notepad and then save it as “.h” file (i.e.) header file. Similarly, all the repeated actions are converted into header files with user defined functions.
In the below example we have created a function by name “Login()” and we have saved the file as “Login.h”. Maintain these header files in a structured folder path for ease of use.
These header files will be called in the desired loadrunner scripts with their function name. For that we need to define the path of the header file in the “global.h” section of the Vugen script. Reason for placing the header files in the global.h section is that it makes the header file globally accessible across the script.
Since the header files are in a location other than the script folder, we have to mention the entire path in the declaration. Also Make sure that the header files exist on the remote Load Generator machine at the same location when running the test from Controller.
After adding the header file, next add the function name in vuser_init()/Action()/vuser_end() section of the script. In our case the function name is Login(); and we have called it from vuser_init().
When we run the script, requests from the header file Login.h (i.e.) the App_Launch & App_Login transactions will be executed in Vugen.
This user defined functions can contain parameters & correlation functions and they will also be executed without any issues. If there are user defined parameters make sure that the same parameter is also created in the script.
Advantages of this framework:
1. Since we are recording all the repeated transactions only once, Scripting time will be drastically reduced.
2. In future if the requests in the header files are modified, then we need to debug only a single header file, instead of reworking on all the scripts. So script debugging time will be drastically reduced.
3. Header files can be stored in a shared path and same can be reused by the team.
No comments:
Post a Comment