I'd like to execute jmeter tests from maven using groovy scripts, but I got the error below. For setting up jmeter and maven I did what is described here .
Shall I package my groovy functions and entities into a jar and copy into jmeter's lib directory and only put those groovy scripts next to the jmx file which contains the sampler code?
2019-06-22 17:40:17,714 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2019-06-22 17:40:17,714 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2019-06-22 17:40:17,744 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script CreateUsers, message: javax.script.ScriptException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script4.groovy: 4: unable to resolve class com.google.gson.Gson
@ line 4, column 1.
import com.google.gson.Gson;
^
You need to add to your pom.xml Gson dependency
<dependency> <groupId>com.google</groupId> <artifactId>gson</artifactId> <version>2.1.0</version> </dependency>
I found the answer:
jmeter/lib
directory The solution for the first is the following from jmeter-maven-plugin doc:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<testPlanLibraries>
<artifact>org.apache.activemq:activemq-spring:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-client:5.15.2</artifact>
<artifact>org.apache.activemq:activemq-broker:5.15.2</artifact>
</testPlanLibraries>
<excludedArtifacts>
<exclusion>com.sun.jdmk:jmxtools</exclusion>
<exclusion>com.sun.jmx:jmxri</exclusion>
</excludedArtifacts>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
The solution for the second is that I need to copy Sampler scripts next to jmx file. Maven can do this easily using maven-resource-plugin .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.