Create a Vuser Script in Visual Studio
LoadRunner Professional's basic IDE add-ins for Visual Studio let you create a Vuser script in Visual Studio in VB, C++, or C#.
Develop a script in Visual Studio
To create your script, you first install the Visual Studio add-in, then use one of the predefined templates.
Prerequisites:
- Visual Studio must be installed in the default location.
- We recommend installing Universal Windows Platform 2017 before installing the 2017 add-in (LRVS2017IDEAddInSetup.exe).
To develop a Vuser script in Visual Studio:
-
Install the IDE add-in for your version of Microsoft Visual Studio from your LoadRunner Professional installation package's Additional Components folder. For example, Additional Components\IDE Add-Ins\LRVS<version>IDEAddInSetup.exe.
-
In Visual Studio, select the appropriate template from the Installed Templates LoadRunner VB|C++|C# .NET Vuser. Visual Studio creates a new project with one class and a template for a Vuser, and the script file, <name>.usr. The template contains three sections, Initialize, Actions, and Terminate.
The following example shows a Visual C# template:
public int Initialize() { // TO DO: Add virtual user's initialization routines return lr.PASS; } public int Actions() { // TO DO: Add virtual user's business process actions return lr.PASS; } public int Terminate() { // TO DO: Add virtual user's termination routines return lr.PASS; }
-
Add code to the template, in the TODO sections.
-
Open the Object Browser (View menu). Expand the LoadRunner node (for example Interop.LoadRunner) to see the LoadRunner Professional elements. Add the desired elements to your script, such as transactions, rendezvous points, and messages.
-
Expand the Toolbar menu, Vuser, and enhance your script with runtime settings and parameters. For more information, see the runtime settings General > Run Logic or the Parameter List dialog box.
-
Use the Vuser menu to replay the script and test its functionality.
-
Select Vuser > Create Load Scenario, to create a LoadRunner Professional scenario using this .usr file.
-
You can also build the LoadRunner Professional project as a DLL file, which will be saved in the same folder as the project. You can reference this DLL directly from a LoadRunner Professional scenario.
Known issues
Visual C++ language | When using the 2015/2017 add-ins for Visual Studio, Visual C ++ language must be installed in order to work with C++ .Net Vuser projects. |
Register .NET assembly |
When using Visual Studio and add-ins to create C# and VB .NET scripts, Visual Studio creates .NET assemblies that need to be registered in the system before their run. Registration of the .NET assembly requires administrative permissions. Resolution: Enable UAC and register the .NET assembly before running the test using one of these methods:
|
VB project |
If you have an issue creating a VB project in Visual Studio 2017, use this workaround:
|
Threads |
Although .NET-based and Java protocols support creating threads, we recommend that you do not use background threads in real load testing scenarios because:
|
See also: