1
votes

I have created a Java project with 1 class containing 2 simple tests, exported as jar and added the jar in my JMeter JUnit folder, now after restarting the JMeter i don't see my class in JMeter even after selecting Annotation 4 option.

This is my class:

package print; 
import org.junit.Test; 
public class PrintClass { 
    @Test public void test() { 
        System.out.println("Hello World..!"); 
    } 
}
4

4 Answers

2
votes

Consider the following checklist:

  1. Your JUnit test class should have either empty constructor or constructor taking a single string as an argument. Other options are not supported
  2. You should place your .jar file(s) under "lib/junit" folder of your JMeter installation
  3. If there are any dependencies you need to put them somewhere in JMeter classpath as well
  4. JMeter restart will be required to pick the .jars up

In case of any problems first of all check jmeter.log file (normally it lives under "bin" folder of your JMeter installation and contains enough troubleshooting information)

See How to Use JUnit With JMeter article for more details.

2
votes

Even I faced same kind of issue then I added the dependency jars to the lib file.

Make sure you copy these files at this location -> apache-jmeter-5.1.1\lib 1.Selenium webdriver jar file (selenium-server-standalone) 2. Junit4 Jar file (junit4)

Make sure you add Jar file from eclipse or any IDE to this location -> apache-jmeter-5.1.1\lib\junit 1. Jar file which contains the automation selenium code (Using Junit)

Restart Jmeter and continue which the normal process of adding thread group and adding Junit sampler etc...

This resolved my issue and I was able to run my scripts on Jmeter.

1
votes

In eclipse make sure that you create a JUnit class, not just the class and add junit annotations to this, even i was facing the same issue, it got resolved when i was created a JUnit class and then uploaded my project in JMeter

0
votes

Did you put the jar in :

  • /lib/junit

Check you jar by running below command to see if it is ok:

jar -tvf <your jar>

And its dependencies as described in:

See this for more details: