1

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..!"); 
    } 
}
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
Suhail Ahmed
  • 504
  • 1
  • 9
  • 19

4 Answers4

2

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.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
2

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

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

Suhail Ahmed
  • 504
  • 1
  • 9
  • 19
0

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:

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • yes, my jar file is saved in /lib/junit folder, can you help me out with the log file, you are talking about the log4j2s.xml file for the logs? – Suhail Ahmed Aug 21 '17 at 07:27
  • no about the file jmeter.log, does it contain an error ? can you share its content? – UBIK LOAD PACK Aug 21 '17 at 07:31
  • Hi i dint find the jemter.log file in bin folder can you help me out with it, i checked with few files, in 1 of the files if got this issue – Suhail Ahmed Aug 21 '17 at 07:51
  • 2017-08-21 13:09:54,120 ERROR o.a.j.e.KeyToolUtils: Exception checking for keytool existence, will return false java.io.IOException: Cannot run program "keytool": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) ~[?:1.8.0_121] at org.apache.jorphan.exec.SystemCommand.run(SystemCommand.java:142) ~[jorphan.jar:3.2 r1790748] at org.apache.jorphan.exec.SystemCommand.run(SystemCommand.java:125) ~[jorphan.jar:3.2 r1790748] – Suhail Ahmed Aug 21 '17 at 07:53
  • You can ignore this one. Try increasing log level to debug in log4j2.xml, restart and share jmeter.log fully not in comment – UBIK LOAD PACK Aug 21 '17 at 07:59
  • NO nothing is happening, i tried... i checked with java and jmeter version mismatch also but nothing is happening... now what i did is i created a simple project with with 1 class containing only 1 method whose function is to print, when i make this as a jar file and add it in lib/junit folder in jmeter event this class dint come up – Suhail Ahmed Aug 29 '17 at 16:21
  • i am using Java 1.8 and jmeter 3.2, eclipse Mars – Suhail Ahmed Aug 29 '17 at 16:22
  • Hi i added java home in my computers System environment, before it was in user environment, now in logs in am not getting any error and now i am again with the same issue i am not seeing my class in jmeter. – Suhail Ahmed Aug 29 '17 at 16:49
  • Hi Thank you, now i am getting my junit test cases jmeter. I have a doubt, before i was creating a class (NOT JUNIT CLASS) and for this class i was adding the JUNIT annotations, this project was not displayed under JUnit, but when i created a new project and this time i create a JUnit class and loaded this class it worked, my project was displayed in JMeter, can you explain me why this happened? – Suhail Ahmed Aug 29 '17 at 16:57
  • can you show your class please ? if answer is ok you should accept it – UBIK LOAD PACK Aug 29 '17 at 18:09
  • package print; import org.junit.Test; public class PrintClass { @Test public void test() { System.out.println("Hello World..!"); } } – Suhail Ahmed Aug 29 '17 at 18:31
  • I have just made a test with your class and it works fine for me. Are you sure your jar is ok ? – UBIK LOAD PACK Aug 29 '17 at 19:23