jmeter plugin maven test-jar
-
25-06-2021 - |
Pregunta
Hi I'm trying to automate my JMeter load balancing test with the jmeter-maven-plugin from lazerycode. My JMeter tests uses premade junit class files which I pack into a test-jar with the maven-jar-plugin. But before the jar file is installed on my local maven repository maven starts the jmeter test. Is there a way I can install the test-jar so I can use it as a dependency in the jmeter plugin? below you'll find my jmeter plugin configuration.
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-test</id>
<phase>integration-test</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>groupID</groupId>
<artifactId>artifactID</artifactId>
<version>${project-version}</version>
<type>test-jar</type>
</dependency>
</dependencies>
<configuration>
<propertiesUser>
<current.protocol>http</current.protocol>
<current.dns>localhost</current.dns>
<current.port>8088</current.port>
</propertiesUser>
<testFilesDirectory>${basedir}/src/jmeter/tests/</testFilesDirectory>
<ignoreResultErrors>true</ignoreResultErrors>
<ignoreResultFailures>true</ignoreResultFailures>
<useOldTestEndDetection>true</useOldTestEndDetection>
</configuration>
</plugin>
thx
Solución
Put the test jar into a different module, then make the project with the jmeter plugin dependent on that module. You will then be able to install the tests then execute them in jmeter in a single Maven invocation.
Otros consejos
I solved this problem by using an activation profile :-
<profiles>
<profile>
<id>ptest</id>
<activation>
<property>
<name>ptest</name>
</property>
</activation>
<build>
<resources>
<resource>
<directory>src/jmeter</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<useOldTestEndDetection>true</useOldTestEndDetection>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Using this approach you can install once, not using the profile, and then run subsequently with the profile turned on.