Develop a Unit Test Using Visual Studio (NUnit test)

The LoadRunner Add-in for Developers enables you to create an NUnit test in Visual Studio for use with LoadRunner.

Note: To run your NUnit test from Controller, make sure that the NUnit framework is installed on the Controller and load generator machines.

To create an NUnit test in Visual Studio:

  1. Install the IDE for Dev add-in for your Microsoft Visual Studio version from your LoadRunner installation package's ..\Additional Components\IDE Add-ins Dev folder. For example, ..\Additional Components\IDE Add-Ins Dev\LRVS<version>IDEAddInDevSetup.exe.

  2. In Visual Studio, open your unit test. This test should comply with the following guidelines:

    • It is a class library

    • There is a reference to the NUnit library, nunit.framework.dll, using nunit.framework. This must have the same NUnit framework version as the one installed on the Controller and load generator machines.

    • At least one of the classes in the project should be a TextFixture (using the [TextFixture] annotation)

  3. In the code, instantiate the LoadRunner API function.

    Example: private LoadRunner.LrApi lr = new LoadRunner.LrApi();

  4. Select DevOps Vuser > Add LoadRunner API Reference to add protocol-specific or general API functions to your test. Alternatively, select Add LoadRunner API Reference from the context menu. Add LoadRunner functionality, such as transactions, think time, messaging, and so forth.

  5. Build the LoadRunner project as a DLL file, which will be saved in the same folder as the project.

  6. Select DevOps Vuser > Run Vuser to run the test with the LoadRunner engine. In the Visual Studio Output window, select Show output from: LoadRunner Information to view the runtime data.

  7. (Optional) Add the DLL as a unit test to an existing or new LoadRunner scenario. For details, see New Scenario Dialog Box.

Back to top