Share this page

# Develop a unit test using Visual Studio (NUnit test)

The add-in for developers enables you to create an NUnit test in Visual Studio for use with OpenText Professional Performance Engineering.

Note:

- To install a Visual Studio add-in, Visual Studio must be installed in the default location.
- To run your NUnit test from Controller, make sure that the NUnit framework is installed on Controller and load generator machines. Define the path to the installed NUnit framework in the Options dialog box. For details, see Options dialog box.

To create an NUnit test in Visual Studio:

1. Install the IDE for Dev add-in for your Microsoft Visual Studio version from your 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 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. Add the following call init method before the API function:

        [OneTimeSetUp]
               public void Init()
               {
                   DriverWrapper.Driver.init();
               }

   The test code should then look like this:

       using System;
       using NUnit.Framework;
       using System.IO;

       namespace nunit2xTest
       {
           [TestFixture]
           public class UnitTest1
           {
               [OneTimeSetUp]
               public void Init()
               {
                   DriverWrapper.Driver.init();
               }

               [Test]
               public void TestMethod1()
               {
                   LoadRunner.LrApi api = new LoadRunner.LrApi();
                   api.start_transaction("test");
                   api.think_time(10);
                   api.output_message("This is test");
                   api.output_message("SingSong");
                   api.end_transaction("test", 0);
                   api.output_message("\n----------------------------");
               }
           }
       }

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

6. Build the project as a DLL file, to be saved in the same folder as the project.

7. Select DevOps Vuser > Run Vuser to run the test with the Controller engine. In the Visual Studio Output window, select Show output from: OpenText Performance Engineering Information to view the runtime data.

8. (Optional) Add the DLL as a unit test to an existing or new scenario. For details, see New Scenario dialog box.

Back to top

See also:

- Create unit tests in external IDEs
- Create and View Vuser Scripts in Visual Studio

https://admhelp.microfocus.com Professional Performance Engineering,VuGen 8942
Tips to improve your search results... OpenText™ Professional Performance Engineering Help Center OpenText™ Professional Performance Engineering Help 26.1 All View Local Help Center View Online Help Center Version: