在从JMeter插件执行JMeter时可以使用jmeter maven-插件吗?
更新
我尝试过按照Ardesco的有用答案将jmeter-plugins依赖项添加到插件定义中,但我得到了大量的ClassNotFoundException。在执行JMeter时,Maven似乎没有将jmeter-plugin的传递依赖项放在类路径上。有什么想法吗?
发布于 2013-08-23 08:28:59
虽然这个答案已被接受,但它只适用于2.X之前的版本。但对于高于2.X的版本,请参见此回答.
是的,您可以通过向插件中添加依赖项来添加所需的任何库,任何显式定义的依赖项都将被复制到jmeter/lib目录中。
如果依赖项是JMeter插件,则可以在配置中指定此插件,然后将该依赖项复制到仪表/lib/ext目录中:
<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>这个功能在1.9.0版本之前就被破坏了。
发布于 2017-12-01 22:47:32
使用2.6.0或更高版本的插件
并增加:
<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>有关使用maven插件的完整概述,请参阅本教程:
发布于 2021-04-29 09:20:26
jmeter 3.4.0
如果您有任何外部依赖项,请使用下面的一个。
<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>您可以检查${project-root}/target/long-folder-name/jmeter/lib/并确保您的jar在那里。对我来说,我需要使用Urirest来创建一个帖子来获取令牌。
https://stackoverflow.com/questions/18361835
复制相似问题