JMeter Plugins when Executing from Maven
Asked Answered
K

3

10

Is it possible to use JMeter Plugins when executing JMeter from the jmeter-maven-plugin?

UPDATE

I've tried adding the jmeter-plugins dependency to the plugin definition as per Ardesco's helpful answer, but I get a myriad of ClassNotFoundExceptions. It seems like Maven is not putting jmeter-plugin's transitive dependencies on the classpath when executing JMeter. Any ideas?

Kalindi answered 21/8, 2013 at 15:38 Comment(1)
D
10

Although this answer is accepted, it only works for versions before 2.X. But for version higher than 2.X, see this answer.

Yup, you can add any libraries you require by adding dependencies to the plugin, any explicitly defined dependencies will be copied to your jmeter/lib directory.

If the dependency is a JMeter plugin you can specify this in your configuration and then that dependency will be copied to your meter/lib/ext directory:

<plugin>
    <groupId>com.lazerycode.jmeter</groupId>
    <artifactId>jmeter-maven-plugin</artifactId>
    <version>1.9.0</version>
    <executions>
        <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
                <goal>jmeter</goal>
            </goals>
            <configuration>
                <jmeterPlugins>
                    <plugin>
                        <groupId>kg.apc</groupId>
                        <artifactId>jmeter-plugins</artifactId>
                    </plugin>
                </jmeterPlugins>
            </configuration>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>kg.apc</groupId>
            <artifactId>jmeter-plugins</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>
</plugin>

This functionality was broken before version 1.9.0.

Dissidence answered 23/8, 2013 at 8:28 Comment(5)
Thanks, but this doesn't work for me - I get java.lang.ClassNotFoundException: org.apache.jorphan.util.JMeterException whenever it tries to run a test.Kalindi
You'll need to raise a bug to get that investigated. It's probably because the plugin isn't loading transitive dependancies right now (Needs investigation). The work around would be to specify the transitive dependancies explicitly.Dissidence
Thanks for replying. I think the issue is slightly different, and whilst you were replying I raised a plugin bug: github.com/Ronnie76er/jmeter-maven-plugin/issues/77Kalindi
Does that load all the plugins, including 'jmeter-plugins-webdriver' plugin or just a certain smaller set?Whoremaster
It should pull in whatever is in the jmeter-plugins jar.Dissidence
W
4

Use version 2.6.0 or upper of the plugin

and add:

<configuration>
    <jmeterExtensions>
         <artifacts>kg.apc:jmeter-plugins-casutg:2.4</artifacts>
    </jmeterExtensions>
    <excludedArtifacts>
        <exclusion>commons-pool2:commons-pool2</exclusion>
        <exclusion>commons-math3:commons-math3</exclusion>
    </excludedArtifacts>
    ...
</configuration>

See this tutorial for a complete overview of using the maven plugin :

Whin answered 1/12, 2017 at 22:47 Comment(0)
N
0

jmeter 3.4.0

If you have any external dependencies please use the below one.

     <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>3.4.0</version>
            <configuration>
                
                <!--testPlanLibraries - if you have any dependency with external jars pls add artifact here-->
                <!-- beanshell preprocessor you can write java so this is useful-->
                <testPlanLibraries>
                     <artifact>com.konghq:unirest-java:3.11.11</artifact>
                 </testPlanLibraries>

                <testFilesDirectory>src/test/jmeter</testFilesDirectory>
                <suppressJMeterOutput>false</suppressJMeterOutput>
                <appendResultsTimestamp>true</appendResultsTimestamp>
                <downloadJMeterDependencies>true</downloadJMeterDependencies>
                <downloadLibraryDependencies>true</downloadLibraryDependencies>
                <downloadExtensionDependencies>true</downloadExtensionDependencies>
                <downloadOptionalDependencies>true</downloadOptionalDependencies>
                <jMeterProcessJVMSettings>
                    <!-- for setting any arguments please use this section -->
                    <arguments>
                        <argument>-Dhttps.use.cached.ssl.context=false</argument>
                        <argument>-Djavax.net.ssl.keyStoreType=jks</argument>
                        <argument>-Djavax.net.ssl.keyStore=${clientCertKeystorePath}</argument>
                        <argument>-Djavax.net.ssl.keyStorePassword=${keyStorePassword}</argument>
                    </arguments>
                </jMeterProcessJVMSettings>
            </configuration>
            <executions>
                <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>
        </plugin>

You can check the ${project-root}/target/long-folder-name/jmeter/lib/ and make sure your jar is present there. For me i have a dependency with Urirest for making a post to get the token.

Noland answered 29/4, 2021 at 9:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.