I want to run JUnit tests for the performance testing using JMeter Maven Plugin. I am creating my project snapshot jar in the target folder. This snapshot jar has test classes and external jars included using maven-assembly-plugin
. The same snapshot jar is able to detect the JUnit test method from the JMeter application and running successfully but not able to detect the same test methods from the plugin when I put that inside <project>/src/test/jmeter/lib/junit
.
I am putting the JMX file inside <project>/src/test/jmeter
and snapshot jar in this folder <project>/src/test/jmeter/lib/junit
.
please find my pom file below.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<!-- Generate JMeter configuration -->
<execution>
<id>configuration</id>
<goals>
<goal>configure</goal>
</goals>
</execution>
<!-- Run JMeter tests -->
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<!-- Fail build on errors in test -->
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
<configuration>
<generateReports>true</generateReports>
<jmeterExtensions>
<artifact>kg.apc:jmeter-plugins:pom:1.4.0</artifact>
<artifact>kg.apc:jmeter-plugins-json:2.7</artifact>
</jmeterExtensions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>MainClass.TestMethod</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>maven-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</project>
I am able to run the same test from JMeter application but the not able to detect the same class from mvn clean verify
command?
The log generated after running mvn clean verify
is below. it says JUnitSampler: ClassNotFoundException:: MyClass.TestMethod
2021-07-12 11:18:38,748 WARN o.a.j.p.j.s.JUnitSampler: ClassNotFoundException:: MyClass.TestMethod
2021-07-12 11:18:38,750 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2021-07-12 11:18:38,750 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1
2021-07-12 11:18:38,750 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2021-07-12 11:18:38,750 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2021-07-12 11:18:38,751 INFO o.a.j.t.JMeterThread: Thread is done: ThreadGroup 1-1
2021-07-12 11:18:38,751 INFO o.a.j.t.JMeterThread: Thread finished: ThreadGroup 1-1
2021-07-12 11:18:40,745 INFO o.a.j.t.JMeterThread: Thread started: ThreadGroup 1-2
2021-07-12 11:18:40,745 WARN o.a.j.p.j.s.JUnitSampler: ClassNotFoundException:: MyClass.TestMethod
2021-07-12 11:18:40,746 INFO o.a.j.t.JMeterThread: Thread is done: ThreadGroup 1-2
2021-07-12 11:18:40,746 INFO o.a.j.t.JMeterThread: Thread finished: ThreadGroup 1-2
2021-07-12 11:18:42,746 INFO o.a.j.t.JMeterThread: Thread started: ThreadGroup 1-3
2021-07-12 11:18:42,746 WARN o.a.j.p.j.s.JUnitSampler: ClassNotFoundException:: MyClass.TestMethod
2021-07-12 11:18:42,746 INFO o.a.j.t.JMeterThread: Thread is done: ThreadGroup 1-3
2021-07-12 11:18:42,747 INFO o.a.j.t.JMeterThread: Thread finished: ThreadGroup 1-3
2021-07-12 11:18:44,748 INFO o.a.j.t.JMeterThread: Thread started: ThreadGroup 1-4
2021-07-12 11:18:44,749 WARN o.a.j.p.j.s.JUnitSampler: ClassNotFoundException:: MyClass.TestMethod