0
votes

I am very new to JMeter

I am trying to use Junit Request sampler in JMeter.In my project we have a class called PayloadProcessorTest.java. from these class methods i am calling some other class methods.It has lot of dependencies

How can i create jar file for PayloadProcessorTest.java with dependencies

I saw many examples for JMeter with Junit Request sampler. But, those all examples are independent classes

Can any one please help me

3

3 Answers

2
votes

There are several ways of creating a .jar file:

  1. Using Maven
  2. Using Ant
  3. Using Eclipse
  4. .jar files are basically ZIP archives so you can just compile your PayloadProcessorTest.java and put resulting PayloadProcessorTest.class into /lib/junit/test.jar file keeping package structure. After restart JMeter will pick up the class. Don't forget to add any 3rd-party jars used in PayloadProcessorTest (if any) to JMeter classpath. For more information check out How to Use JUnit With JMeter guide.
0
votes

If you want to get the dependencies with Maven you can run mvn install dependency:copy-dependencies, which will create a folder inside your target folder called 'dependency' filled with the dependencies. To speed this up you can add the command as External Tool in Eclipse using Run > External Tools > External Tools Configurations.

Or if you want to use Eclipse you can choose File > Export > Java > Runnable JAR file and select the option 'Copy required libraries into a sub folder next to the generated JAR'. However to do this you will need to add a main class, and run it once as a Java Application before trying to export. The Main class can be empty or not.

package test;

public class Main {
 public static void main(String[] args) {

 }
}
-3
votes

Really, it depends what packaging capabilities you have.

You need to compile your classes in one or more jars, and then put them in the %JMETER_HOME%/lib/ext folder.

Or use maven to do it all for you.