3

Integrating JMeter as part of Maven project

Extending the above question, is the possible to do the below steps through maven dependency itself, ideally we don't want to rely on the local installation of JMeter for running the test and don't want to use JMeter Maven Plug-in since we cannot specify which JMeter version we want to use to run the JMeter Script.

The answer mentioned is to use AntRunner but not sure how to do that through maven any pointer will be helpful

My scenario is to,

Download and Unzip the JMeter official distribution as maven dependency

Copy to target folder

JMeterUtils.setJMeterHome("copied-target-folder/bin")

jmeter.run();

Community
  • 1
  • 1
Shan
  • 75
  • 9
  • Actually you can set the JMeter version in the jmeter-maven-plugin: https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/src/main/java/com/lazerycode/jmeter/mojo/ConfigureJMeterMojo.java#L59 – Ardesco Sep 27 '16 at 13:34
  • You can also just have a look at the code in the jmeter-maven-plugin to see how that pulls down JMeter as a maven dependency. – Ardesco Sep 27 '16 at 13:35

2 Answers2

1

You can use AntRunner and the following Ant tasks:

Example:

<get src="url of jmeter"
     dest="${build.dir}/${zip}"
     usetimestamp="true" ignoreerrors="false"/>
<unzip dest="${build.dir}" src="${build.dir}/${zip}">
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • Thanks for quick help, I just need to add explicit proxy as part of my ant task to get it working behind my corporate firewall – Shan Aug 24 '16 at 17:58
0

The maven-dependency-plugin has a goal called unpack which downloads a dependency (using maven coordinates) and unpacks it on a local directory. You can use that goal to download a given JMeter instance.

The syntax would go like this (not tested, you will have to adjust it):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.10</version>
    <executions>
        <execution>
            <id>unpack</id>
            <phase>process-test-classes</phase>
            <goals>
                <goal>unpack</goal>
            </goals>
            <configuration>
                <artifactItems>
                    <artifactItem>
                        <groupId>org.apache.jmeter</groupId>
                        <artifactId>jmeter</artifactId>
                        <version>1.0</version>
                        <type>zip</type>
                        <overWrite>false</overWrite>
                        <outputDirectory>target/jmeter</outputDirectory>
                    </artifactItem>
                </artifactItems>
            </configuration>
        </execution>
    </executions>
</plugin>

That would fulfill your first step:

Download and Unzip the JMeter official distribution as maven dependency

But I'm not sure there is a full zip version of JMeter published as a Maven dependency. You can unpack the jar files, maybe that's enough. Or maybe you just need to execute those ant steps.

You can execute any ant script (build.xml) using the antrunner plugin. You can find documentation and examples on the Maven AntRun Plugin page.

sargue
  • 5,695
  • 3
  • 28
  • 43