【问题标题】:jmeter maven - running jmx file gives Error: Could not find or load main class org.apache.jmeter.NewDriverjmeter maven - 运行 jmx 文件给出错误:无法找到或加载主类 org.apache.jmeter.NewDriver
【发布时间】:2015-12-10 01:27:45
【问题描述】:

为 jmeter 设置一个 maven 项目。 在 src/test/java 中添加 jmx 文件。

尝试运行 jmx 文件时,在控制台中收到以下错误。 错误:无法找到或加载主类 org.apache.jmeter.NewDriver

这是我的 pom.xml

<?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>com.companyname.automation</groupId>
    <artifactId>apiautomation</artifactId>
    <version>1.0-SNAPSHOT</version>


    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>1.4.1</version>
            </plugin>
        </plugins>
    </build>

    <dependencies>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient-osgi</artifactId>
        <version>4.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.3-beta1</version>
    </dependency>
</dependencies>

【问题讨论】:

  • 尝试使用最新的插件。版本是1.10.1

标签: maven jmeter


【解决方案1】:

您的设置中存在一些不一致之处:

  1. JMX 文件应位于 src/test/jmeter 文件夹下
  2. 您需要在&lt;version&gt;1.4.1&lt;/version&gt; 行之后添加以下部分:

    <executions>
        <execution>
            <id>jmeter-tests</id>
            <phase>verify</phase>
            <goals>
                <goal>jmeter</goal>
            </goals>
        </execution>
    </executions>
    
  3. 使用mvn clean verify 运行您的测试。

参考资料:

【讨论】:

  • 是的,根据文档,这是您应该做的。将您的 jmx 文件移到那里
  • 谢谢德米特里。在我更改了 pom 并创建了必要的文件夹结构后,我的测试运行良好。
猜你喜欢
  • 1970-01-01
  • 2015-06-04
  • 2020-08-29
  • 1970-01-01
  • 1970-01-01
  • 2017-07-30
  • 2012-06-22
  • 1970-01-01
相关资源
最近更新 更多