How to Develop a Unit Test Using Visual Studio (NUnit test)

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

To create an NUnit test in Visual Studio:

  1. Install the IDE for Dev add-in for your Microsoft Visual Studio version from the download or DVD Additional Components\IDE Add-ins Dev folder. For example Additional Components\IDE Add-Ins Dev\LRVS2012IDEAddInDevSetup.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;
    • 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. For 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