0

I added the Jmeter plugin to my project and now its load tests are running together with the maven build.

  <!-- Jmeter  -->
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.9.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I wanted Jmeter tests to run just by running the command:

mvn jmeter:jmeter -Pjmeter

I didn't want it to run when performing any maven lifecycle like for example:

mvn install

As the tests are performed in a Restful API the load test will be performing POST and creating data in the database every time a maven lifecycle is run.

Can someone help me?

1 Answers1

0

Just put your JMeter Maven Plugin declaration under the jmeter profile like:

<profiles>
    <profile>
        <id>jmeter</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.lazerycode.jmeter</groupId>
                    <artifactId>jmeter-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <executions>
                        <!-- Generate JMeter configuration -->
                        <execution>
                            <id>configuration</id>
                            <goals>
                                <goal>configure</goal>
                            </goals>
                        </execution>
                        <!-- Run JMeter tests -->
                        <execution>
                            <id>jmeter-tests</id>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                        <!-- Fail build on errors in test -->
                        <execution>
                            <id>jmeter-check-results</id>
                            <goals>
                                <goal>results</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

this way JMeter maven plugin will be executed only if you explicitly specify the jmeter profile

Demo:

enter image description here

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133