jmeter maven - running jmx file gives Error: Could not find or load main class org.apache.jmeter.NewDriver

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

Setup a maven project for jmeter. Added the jmx file in src/test/java.

When trying to run the jmx file, getting the following error in the console. Error: Could not find or load main class org.apache.jmeter.NewDriver

Here is my 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:

There are few inconsistencies in your setup:

  1. JMX file(s) should live under src/test/jmeter folder
  2. You need to add the following section after <version>1.4.1</version> line:

    <executions>     <execution>         <id>jmeter-tests</id>         <phase>verify</phase>         <goals>             <goal>jmeter</goal>         </goals>     </execution> </executions>
  3. Use mvn clean verify to run your test.

References:



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!