Note |
---|
Please note: the JMeter Maven plugin is a 3rd party product; it is not part of the Apache JMeter project |
JMeter Maven Plugin
A more recent version of this wiki page can be found here
https://github.com/Ronnie76er/jmeter-maven-plugin/wiki
This is a Maven 2 3 plugin that allows you to run JMeter tests as part of the build. I am using this with JChav and Continuum to automate the running of a suite of JMeter load tests, and publish the results to a web page. Sorry this is not more polished. It could use some TLC to make it more user-friendly to actually plug it into a project. I just thought I'd stick the code out there as quickly as possible and see if anyone is interested in it before I went any further with it.
To build and use the plugin:
Remote Repository
- Create a locally hosted remote Maven repository, if you don't already have one.
- Configure your pom to utilize this remote repository.
Deploy JMeter Jar
...
No Format |
---|
mvn deploy:deploy-file -DgroupId=org.apache.jmeter -DartifactId=jmeter -Dversion=2.2 -Dpackaging=jar -Dfile=c://downloads//jmeter//jmeterPlugin/jmeter-2.2.jar -DpomFile=c://downloads//jmeter//jmeterPlugin/jmeter-2.2.pom -Durl=file:////myRepoHost.com/FileShare/ProductDevelopment/ApplicationDevelopment/maven2repository -DrepositoryId=my-repo
|
Deploy Dependencies
- Add the jar files that are referenced in the JMeter POM to your local repository, via the deploy plugin, if they are not on ibiblio.
Install the Plugin
...
Install the Plugin
This plugin is available from the maven central repository, as long as you have a working install of maven you only need to create a valid pom.xml that references this plugin.
Basic Configuration
...
No Format |
---|
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>maven-jmeter-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
|
Configure the Plugin
- Create a src/test/jmeter directory, and place your JMeter load tests there.
- Create a jmeter.properties file in src/test/jmeter. It's fine to just copy the default properties file from the JMeter install if you want.
Add the plugin to your pom.xml
Optionally configure includes and excludes in your pom.xml for which tests to run. If you don't, it will just run **/*.jmx. For example:No Format +---+ <project> [...] <build>
No Format <build> <plugins> <plugin> <groupId>org.apache.jmeter</groupId> <artifactId>maven-jmeter-plugin</artifactId> <configuration> <includes> <include>myTest1.jmx</include> <include>myTest2.jmx</include> </includes> </configuration> </plugin><pluginManagement> </plugins> </build>
- The default reports directory is 'jmeter-reports' which is created in the base folder ( usually where maven is run from )
- Changing the reports directory : Add a reportDir setting to the plugin configuration. for example:
No Format <build> <plugins> <plugin> <groupId>org.apache.jmeter</groupId> <artifactId>maven-jmeter-plugin</artifactId> <plugin> <configuration> <includes> <include>myTest1.jmx</include> <include>myTest2.jmx</include><groupId>com.lazerycode.jmeter</groupId> </includes> <reportDir>target/jmeter-reports</reportDir> </configuration> </plugin> </plugins> </build>
Executing the Plugin
- Run "mvn org.apache.jmeter:maven-jmeter-plugin:jmeter" to run the tests.
Change to the plugin - by Peter Andersen / not committed!
(If this can be used - please commit this into the codebase)
Using jmeter from maven-jmeter-plugin as suggested on:
http://jlorenzen.blogspot.com/2008_03_01_archive.html
The problem is that maven hang after the test has ended.
Some debugging shows that the maven-jmeter-plugin call to jmeter course jmeter to leak threads, I have done the following change to the maven-jmeter-plugin that fixes the problem, using checkForEndOfTest method below.
Hope someone can use this to improve the plugin.
Code changes to org.apache.jmeter.JMeterMojo.java:
...
<artifactId>jmeter-maven-plugin</artifactId>
...
<version>2.
...
8.5</version>
...
<executions>
...
<execution>
...
<id>jmeter-tests</id>
...
<goals>
...
<goal>jmeter</goal>
...
</goals>
...
</execution>
...
<execution>
...
<id>jmeter-check-results</id>
...
<goals>
...
<goal>results</goal>
...
</goals>
...
</execution>
...
</executions>
...
</plugin>
...
</plugins>
...
</pluginManagement>
...
</build>
...
[...] </project> +---+
Executing the Plugin
- Run "mvn clean verify" to run the tests (Best practice would be to assign the JMeter tests to a specific profile so that they only run when invoking that profile).
External Links
The source code for this plugin can be found at https://github.com/jmeter-maven-plugin/jmeter-maven-plugin
The official website is available at https://jmeter.lazerycode.com
The github wiki has more detailed configuration information and is available at https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki
Tutorial