We wanted to run Junit Test in Loadrunner and below is the code written in eclipse: When i run the code in eclipse i get NoClassDefFoundError Exception. From Loadrunner Vugen Folder I zipped the "lr.class" file and imported it in the eclipse Jar libraries.
import classes.lrapi.lr;
import org.junit.Test;
public class Jtst {
@Test
public void tst() {
System.out.println("Tst method");
try{
lr.start_transaction("T11");
//lr.start_transaction("T1");
System.out.print("Executing...");
lr.end_transaction("T1",lr.PASS);
}catch (Exception e){
e.printStackTrace();
}
}
public static void main(String args[]) throws ClassNotFoundException
{
System.out.println("Main");
Jtst j1 = new Jtst();
j1.tst();
}
}
When i run the program I get the Exception NoClassDefFoundError Please find below the error message.
java.lang.NoClassDefFoundError: lrapi/lr
at Jtst.tst(Jtst.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run
The easyest way to add a references to LoadRunner API is by using LoadRunner developer's add-in.
To use it (from LoadRunner user guide):