简体   繁体   中英

How to set Jmeter home in pom.xml?

The following is my pom.xml

  <build>
    <plugins>
      <plugin>
        <groupId>com.lazerycode.jmeter</groupId>
        <artifactId>jmeter-maven-plugin</artifactId>
        <version>2.2.0</version>
        <executions>
          <execution>
            <id>jmeter-tests</id>
            <goals>
              <goal>jmeter</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <propertiesJMeter>

          </propertiesJMeter>
        </configuration>
      </plugin>
    </plugins>
  </build>

When I run the .jmx, I get the following message:

Error: Could not find or load main class org.apache.jmeter.NewDriver

I notice that the classpath for org.apache.jmeter.NewDriver is wrong. How do I set it to Jmeter's home in the pom.xml, or in the .jmx file?

There is no such concept as JMeter home when it comes to executing tests via Maven plugin, all you need to do is to:

  1. Set up your pom.xml file to look like:

     <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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.blazemeter</groupId> <artifactId>mvn-jmeter</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>maven-jmeter-demo</name> <url>http://maven.apache.org</url> <build> <plugins> <plugin> <groupId>com.lazerycode.jmeter</groupId> <artifactId>jmeter-maven-plugin</artifactId> <version>2.2.0</version> <executions> <execution> <id>jmeter-tests</id> <phase>verify</phase> <goals> <goal>jmeter</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> 
  2. Set up your project to look like:

    • src
      • test
        • jmeter
          • test.jmx
          • here you can put another jmx if needed
    • pom.xml
  3. Run your test like mvn clean verify

JMeter Maven plugin will download JMeter along with dependencies (you will be able to find in under target/jmeter folder along with JMeter logs ( logs folder) and test results ( results folder)

More information:

You CAN use Jmeter home with the Maven plugin. You just have to take one more step after editing your pom as described above.

In your projects directory, open up your cmd and run a specific execution to the Jmeter goal; eg : mvn com.lazerycode.jmeter:jmeter-maven-plugin:2.7.0:jmeter

Equivalent statement : mvn groupId:artifactId:version:goal (based on POM structure of plugin)

This will generate the Jmeter directory inside of your target directory. You can then use it as the Jmeter home for the code you're trying to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM