3

尝试使用 maven 项目执行 .jmx (Jmeter)。在 Jmeter 3.1 版本中创建了 jmx 文件。使用 jmeter-maven-plugin 2.1.0。使用 - mvn clean verify 在命令行中执行时出现以下错误

[INFO]  P E R F O R M A N C E    T E S T S
[INFO] -------------------------------------------------------
[INFO] Invalid value detected for <postTestPauseInSeconds>.  Setting pause to 0...
[INFO]
[INFO]
[INFO] Executing test: CCMTestPlan.jmx
[INFO] Writing log file to: E:\jmeter-mvn-master\jmeter-mvn-  master\target\jmeter\logs\CCMTestPlan.jmx.log
[INFO] Error in NonGUIDriver java.lang.IllegalArgumentException: Problem loading XML from:'E:\jmeter-mvn-master\jmeter-mvn-master\target\jmeter\testFiles\CCMTestPlan.jmx', missing class com.thoughtworks.xstream.converters.ConversionException:
[INFO] ---- Debugging information ----
[INFO] cause-exception     : com.thoughtworks.xstream.converters.ConversionException
[INFO] cause-message       :
[INFO] first-jmeter-class  : org.apache.jmeter.save.converters.HashTreeConverter.unmarshal(HashTreeConverter.java:67)
[INFO] class               : org.apache.jmeter.save.ScriptWrapper
[INFO] required-type       : org.apache.jorphan.collections.ListedHashTree
[INFO] converter-type      : org.apache.jmeter.save.ScriptWrapperConverter
[INFO] path                : /jmeterTestPlan/hashTree/hashTree/hashTree/hashTree[3]/com.atlantbh.jmeter.plugins.jsonutils.jsonpathextractor.JSONPathExtractor
[INFO] line number         : 98
[INFO] version             : 3.1 r1770033
[INFO] -------------------------------

以下是我的 pom.xml 文件

<build>
    <plugins>
    <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>2.1.0</version>
        <configuration>
            <testResultsTimestamp>false</testResultsTimestamp>
            <jmeterPlugins>
                <plugin>
                   <groupId>kg.apc</groupId>
                   <artifactId>jmeter-plugins-extras-libs</artifactId>
                </plugin>
            </jmeterPlugins>   
            <testFilesIncluded>
                      <testFilesIncluded>CCMTestPlan.jmx</testFilesIncluded>
            </testFilesIncluded>   
            <jmeterVersion>3.1</jmeterVersion>         
        </configuration>
        <executions>
            <execution>
                <id>jmeter-tests</id>
                <phase>verify</phase>
                <goals>
                    <goal>jmeter</goal>
                </goals>                
            </execution>
        </executions>
        <dependencies>
            <dependency>
               <groupId>kg.apc</groupId>
               <artifactId>jmeter-plugins-extras-libs</artifactId>
               <version>1.3.1</version>
            </dependency>
        </dependencies>
    </plugin>
    </plugins>
</build>

有人遇到过这个问题吗?

4

2 回答 2

2

插件的 2.x 版本中的依赖配置已更改(请参阅 https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/wiki/Adding-additional-libraries-to-the-classpath

将 jar 添加到 /lib/ext 目录

您可以使用<jmeterExtensions>配置元素将任何其他 Java 库添加到 JMeter 的 lib/ext 目录。这使用 Eclipse Aether 库来执行依赖关系解析。

<project>
    [...]
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>2.1.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <jmeterExtensions>
                            <artifact>kg.apc:jmeter-plugins:pom:1.3.1</artifact>
                        </jmeterExtensions>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    [...]
</project>
+---+

当你正确定义你的依赖时,你可能会看到另一个错误,因为 jmeter-plugins 依赖于 JMeter 2.13,它有一个损坏的 maven 依赖树。这是 jmeter-plugins 团队需要解决的问题(他们需要发布依赖于 JMeter 3.1 的 jmeter 插件版本)。

构建将中断,因为插件正在尝试为不存在的 jmeter-plugins 下载一些传递依赖项,您可以通过设置解决此问题:

<downloadExtensionDependencies>false</downloadExtensionDependencies>

然而,这确实意味着您需要手动设置 jmeter-plugins 在您的<jmeterExtensions>块中依赖的所有依赖项。

您可以使用mvn dependency:tree获取 jmeter-plugins-extras-libs 包所需的完整依赖项列表。

上述信息尚未进入 Wiki(添加此信息并将所有内容移至网站的任务正在进行中),但可在 CHANGELOG 中找到:

https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/blob/master/CHANGELOG.md

于 2017-03-06T10:42:23.473 回答
0
use This it will work

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>jmeter</groupId>
   <artifactId>qbo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>jar</packaging>
   <name>qbo</name>
   <url>http://maven.apache.org</url>
   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
   <build>
      <plugins>
         <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>2.1.0</version>
            <configuration>
               <testResultsTimestamp>false</testResultsTimestamp>
            </configuration>
            <executions>
               <execution>
                  <configuration>
                     <testFilesDirectory>src/test/jmeter/</testFilesDirectory>
                  </configuration>
                  <id>jmeter-tests</id>
                  <phase>verify</phase>
                  <goals>
                     <goal>jmeter</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>
于 2018-02-04T04:49:39.757 回答