This blog was written by Boris Kozorovitzky from PerfCore RnD team
For the vast majority of LoadRunner/Performance Center/StormRunner Load users, VuGen is the main IDE to develop performance test scripts. Many of these users have a directory with multiple VuGen solutions and even more scripts arranged to perform particular use cases on one or more applications under test. Some of these scripts perform similar actions and differ only slightly from each other. For example, multiple scripts may require you to run a login action before any other action within the script. The common practice today is to copy the shared action files from one script to another—resulting in a maintainability challenge. VuGen does not provide any out-of-the-box functionality to manage shared actions between the scripts of a solution. In this article, I explore a different approach to this problem by utilizing an existing operating system feature available since Window Vista – the symbolic links.
In an empty directory, I created two scripts “MyScript_1” and “MyScript_2” and saved them in a solution called “MySolution”. Note: the protocols of the scripts are not important for the scope of this article.
In the first use case I want to share an action called “login” between the scripts. The process is a little cumbersome but we might be able to improve it later, bear with me. The first thing I do is create the “login” action in both scripts. This can be done by right-clicking the “actions” node in the project explorer of each script and select the “Create New Action” menu item. The end result is something like this:
Next, I create a new directory named “Shared”, in the parent directory of the two scripts (through the Windows File Explorer). This directory will contain my shared resources and. In the “Shared” directory I create a directory called “Actions” that will soon contain the shared action file.
To create the shared action I copy login.c from one of the scripts into the “Actions” directory and delete the login.c file from both scripts through the file system. Don’t do it through VuGen or the scripts will lose track of the action!
The final result looks something like this:
Now comes the tricky part when I create the symbolic links for the shared action. To create a symbolic link I open a new CMD window in administrator mode and “cd” into the main project directory (where I have the two script directories and my “Shared” directory) and run the following commands:
The above Windows commands will create two symbolic links, each in a different script folder, pointing to the shared “login.c” file
CAVEAT: If you try to edit the login actions through VuGen the symbolic link will be broken, perhaps in the future VuGen will prevent that but until then, be careful.
Now I can edit the login.c file from the shared directory and see how both actions are updated:
After I created the shared action I want to make sure that the scripts still work with various VuGen functions.
Replay in VuGen:
Replay in Controller: Script was properly copied to the remote LG
Git integration fails to properly commit the file into Git. It looks like a Git problem and not a VuGen problem because it happens with other Git clients as well.
Export to zip added the file properly into zip but the symlink will be lost when extracting.
I expect uploading to ALM will work the same as with zipped scripts, but I did not test that particular use case.
Not many are aware of the fact that VuGen can be extended with your own commands. I created two such commands as a VuGen addin (attached). Simply extract the content of the zip into the <LoadRunnerDir>\AddIns\VuGen\FrontEnd directory and start VuGen as an administrator (creating symbolic links requires administrator privileges, nothing we can do about it). The addin will help you automate some of the processes discussed in this article such as creating the shared action and linking an existing action to the shared one (especially useful if you edited the action in the script and need to re-link it to the shared one).
Now you have two new commands from the context menu of the project explorer:
Right-clicking on the “Actions” reveals a new command “Create new shared action”. Clicking this menu item will create an action in the script but will then ask you to link it to a shared directory where a shared action file will be created.
Right-clicking on a specific action revels a new command “Link to shared action”. Clicking this menu item will ask you to link the regular action to a shared action file with the same name. This is also useful if you accidently edit the action file within the script and not the shared action.
Here is an example of an actual usage of the extension:
It is possible (yet very cumbersome) to share actions between scripts. Currently there is no official support for any kind of action sharing but with some careful manipulations on the file system we can achieve a working solution that is very efficient in many cases. If you found this method useful and used it in your projects please tell us in the comments section. If you would like to have official support for shared actions within VuGen don’t forget to hit that feedback button in VuGen (Help menu) and tell us about it.