2
votes

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
Try using the latest plugin. The version is 1.10.1Deepti K

1 Answers

1
votes

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: