Share this page

# Develop a unit test using Eclipse (JUnit test)

The Eclipse Add-in for Developers enables you to create a JUnit test using Eclipse.

Note:

- For supported Eclipse and JDK/JRE versions, see Supported Protocols.
- If you have a previously installed version of the Eclipse Add-in for Developers (for versions earlier than 26.1), you must reinstall it. For details, see Create a JUnit test
- The following procedure is also applicable if you are using Selenium with your JUnit test.

In this topic:

## Prerequisites

Make sure you have a supported JDK version installed on the Eclipse machine. The Eclipse add-in requires Eclipse to run on JDK 17 or later.

After setting up the JDK, you must set the JRE version in Eclipse.

### Set Eclipse machine to automatically use JDK 17

If there are additional Java versions earlier than Java 17 installed on the machine, then use one of the following methods to ensure Eclipse runs using Java 17 (or your later version):

Option 1: Configure Eclipse to explicitly use Java 17:

In the eclipse.ini file (located in the same directory as eclipse.exe), add the following lines before -vmargs:

Copy code

              -vm
              C:/<path-to-Java-17>/bin/javaw.exe

Option 2: Configure Java 17 at the system level

1. Set the JAVA_HOME environment variable to:

   `C:\<path-to-Java-17>\`

2. Add `%JAVA_HOME%\bin` to the Path environment variable.

To update the JRE version in Eclipse:

1. In the Eclipse workspace, select Window > Preferences.
2. Navigate to the Java > Installed JREs node. If the installed version is not in the Installed JREs list, click Add and use the wizard to add its folder, for example, C:\Program Files\Java\jreXX.
3. In the Installed JREs list, click the appropriate check box to instruct Eclipse to use this version.
4. Close Eclipse.

(missing or bad snippet)

## Create a JUnit test

Using the add-in for Eclipse allows you to create JUnit tests that can be called directly from the testing application, such as Controller, without having to open them in VuGen.

To create a unit test in Eclipse:

1. Run the Eclipse Add-in for Developers, LREclipseIDEAddInDevSetup.exe, from your installation package's Additional Components\IDE Add-Ins Dev folder. Check during installation that the displayed Eclipse path is correct.

   After installing the Eclipse add-in, rebuild the plugin cache by running the following command line string: Eclipse.exe -clean.

   Note: If you are running multiple instances of Eclipse and you want to use the add-in for each instance, you must manually install the Eclipse Add-in for Developers for each instance. Locate the hp.lr.continuousdelivery.eclipse42addin.jar file in the <installdir>\bin folder, and copy it to the dropins folder for each Eclipse instance.

2. In Eclipse, open your JUnit test.

3. Code the test as you normally would in Eclipse.

4. Build your Java classes.

5. Select DevOps Vuser > Add OpenText Performance Engineering API Reference to add the required functions to your script, as well as transactions, rendezvous points, and messages.

   Tip: If the DevOps Vuser menu is not visible in the Eclipse menu bar, go to the <installdir>\bin folder, locate the hp.lr.continuousdelivery.eclipse42addin.jar file, and copy it to the Eclipse dropins folder.

6. Select DevOps Vuser > Run Vuser to run the test from within Eclipse to verify its functionality.

   Tip: Check the Eclipse console log for errors, and try the following to resolve issues:

   - JDK not found. Check that Java is installed correctly.
   - JDK found, Mdrv exit code is 1. Increase the JVM heap size.
   - JDK found, logs show some package(s) can’t be found. Check that the packages exist.

7. Once the previous step is successfully completed, use the DevOps Vuser menu to launch Controller, or add the test to a Controller scenario that is already open.

   Alternatively, export the project as a .jar file, then add the test to Controller as System or Unit Tests.

   Tip: When exporting as a .jar file, please export without dependent class files.

8. The class file can be added to a scenario at any time, as a unit test. For details, see New Scenario dialog box.

## See also

- Video: Integration with Eclipse
- Create Vuser scripts in external IDEs

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-26.3 All View Local Help Center View Online Help Center Version: