Develop a unit test using Eclipse (JUnit test)
The LoadRunner Professional Eclipse Add-in for Developers lets you create a JUnit test using Eclipse.
- For supported Eclipse and JDK/JRE versions, see the Support Matrix.
- The following procedure is also applicable if you are using Selenium with your JUnit test.
To create a unit test in Eclipse:
Prerequisite: Make sure you have a supported JDK version installed on your machine. Go to java.com to check your version or download the required version.
Open Eclipse and select Window > Preferences. Navigate to the Java > Installed JREs node. If the relevant version (for example, jre8) is not in the Installed JREs list, click Add and use the wizard to add its folder (for example, C:\Program Files\Java\jre8).
In the Installed JREs list, click the check box by the relevant version (for example, jre8) to instruct Eclipse to use this version.
Run the Eclipse Dev add-in, LREclipseIDEAddInDevSetup.exe, from your LoadRunner Professional 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.
In Eclipse, open your JUnit test.
Code the test as you normally would in Eclipse.
Build your Java classes.
Select DevOps Vuser > Add LoadRunner API Reference to add the required LoadRunner Professional 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 <LoadRunner Professional root>\bin folder, locate the hp.lr.continuousdelivery.eclipse42addin.jar file, and copy it to the Eclipse dropins folder.
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.
Once the previous step is successfully completed, use the DevOps Vuser menu to launch LoadRunner 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.
The class file can be added to a LoadRunner Professional scenario at any time, as a unit test. For details, see New Scenario dialog box.
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 <LoadRunner Professional root>\bin folder, and copy it to the dropins folder for each Eclipse instance.