Ashish Bhatia
Ashish Bhatia

Reputation: 629

Junit Test case run in STS successfully although can not run through Jmeter.

I have a Java project in Spring tools editor. When I run test cases in spring it gets executed. Although When I export it in jar and put in Jmeter/lib/junit. and pick junit request sampler in Jmeter it fails with

018-11-30 14:06:30,854 ERROR o.a.j.JMeter: Uncaught exception: java.lang.ExceptionInInitializerError: null at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_181] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_181] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_181] at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_181] at org.apache.jmeter.protocol.java.sampler.JUnitSampler.getClassInstance(JUnitSampler.java:534) ~[ApacheJMeter_junit.jar:5.0 r1840935] at org.apache.jmeter.protocol.java.sampler.JUnitSampler.initializeTestObject(JUnitSampler.java:658) ~[ApacheJMeter_junit.jar:5.0 r1840935] at org.apache.jmeter.protocol.java.sampler.JUnitSampler.threadStarted(JUnitSampler.java:646) ~[ApacheJMeter_junit.jar:5.0 r1840935] at org.apache.jmeter.threads.JMeterThread$ThreadListenerTraverser.addNode(JMeterThread.java:762) ~[ApacheJMeter_core.jar:5.0 r1840935] at org.apache.jorphan.collections.HashTree.traverseInto(HashTree.java:994) ~[jorphan.jar:5.0 r1840935] at org.apache.jorphan.collections.HashTree.traverse(HashTree.java:977) ~[jorphan.jar:5.0 r1840935] at org.apache.jmeter.threads.JMeterThread.threadStarted(JMeterThread.java:730) ~[ApacheJMeter_core.jar:5.0 r1840935] at org.apache.jmeter.threads.JMeterThread.initRun(JMeterThread.java:718) ~[ApacheJMeter_core.jar:5.0 r1840935] at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249) ~[ApacheJMeter_core.jar:5.0 r1840935] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181] Caused by: java.lang.NullPointerException at com.autodesk.acmtest.config.env.EnvConfigs.loadFromPropertiesFile(EnvConfigs.java:38) ~[acm_test.jar:?] at com.autodesk.acmtest.config.env.EnvConfigs.loadFromSystemProperties(EnvConfigs.java:30) ~[acm_test.jar:?] at com.autodesk.acmtest.config.Configs.getEnvConfig(Configs.java:34) ~[acm_test.jar:?] at com.autodesk.acmtest.cases.BaseTests.(BaseTests.java:11) ~[acm_test.jar:?] ... 14 more 2018-11-30 14:06:30,858 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test 2018-11-30 14:06:30,859 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, local)

I am using Jmeter 5.0 and Java 1.8. Any help is really appreciated.

Upvotes: 0

Views: 256

Answers (1)

Dmitri T
Dmitri T

Reputation: 168072

Looking into the error cause:

Caused by: java.lang.NullPointerException at com.autodesk.acmtest.config.env.EnvConfigs.loadFromPropertiesFile(EnvConfigs.java:38) ~[acm_test.jar:?] at

My expectation is that you forgot to copy some ".properties" file along with your JUnit test configuration, if you use relative paths - most probably you should put the file to JMeter's "bin" folder.

Alternatively looking into EnvConfigs.loadFromSystemProperties line you can perform the configuration in system.properties file (it lives in "bin" folder of your JMeter installation) or provide the values via -D command line arguments like:

jmeter -Dparameter1=value1 -Dparameter2=value2 -n -t test.jmx -l result.jtl

More information:

Upvotes: 1

Related Questions