【问题标题】:JMeter Plugins when Executing from Maven从 Maven 执行时的 JMeter 插件
【发布时间】:2013-08-21 15:38:48
【问题描述】:

jmeter-maven-plugin执行JMeter时是否可以使用JMeter Plugins

更新

我已尝试根据 Ardesco 的有用答案将 jmeter-plugins 依赖项添加到插件定义中,但我得到了无数的 ClassNotFoundExceptions。 似乎 Maven 在执行 JMeter 时没有将 jmeter-plugin 的传递依赖项放在类路径上。有什么想法吗?

【问题讨论】:

标签: maven jmeter jmeter-plugins jmeter-maven-plugin


【解决方案1】:

虽然这个答案被接受,但它只适用于 2.X 之前的版本。 但对于高于 2.X 的版本,请参阅此answer

是的,您可以通过向插件添加依赖项来添加所需的任何库,任何明确定义的依赖项都将复制到您的 jmeter/lib 目录。

如果依赖项是 JMeter 插件,您可以在配置中指定它,然后该依赖项将被复制到您的meter/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 版之前被破坏。

【讨论】:

  • 谢谢,但这对我不起作用 - 每当它尝试运行测试时,我都会收到 java.lang.ClassNotFoundException: org.apache.jorphan.util.JMeterException
  • 您需要提出一个错误来进行调查。这可能是因为插件现在没有加载传递依赖(需要调查)。解决方法是明确指定传递依赖。
  • 感谢您的回复。我认为问题略有不同,当您回复时,我提出了一个插件错误:github.com/Ronnie76er/jmeter-maven-plugin/issues/77
  • 是否加载所有插件,包括“jmeter-plugins-webdriver”插件或只是某个较小的集合?
  • 它应该拉入 jmeter-plugins jar 中的任何内容。
【解决方案2】:

使用 plugin 的 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 插件的完整概述,请参阅本教程:

【讨论】:

    【解决方案3】:

    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 来发帖获取令牌。

    【讨论】:

      猜你喜欢
      • 2013-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-11
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多