In this article, weâll cover how to define the way of platform independent JMeter script execution with the help of jmeter-maven-plugin to make our life easy in Performance testing phase. As technology changes every day, adopting to better solutions will make us SMEs in those areas. 


The following points were important:

  1. The plugin avoids the dependency of JMeter installation on the script execution machine. 
  2. It must be possible to start the JMeter test from command line (without gui).
  3. The JMeter GUI should also be accessibla directly via the plugin (e.g. via a separate Maven goal).
  4. Plugin enables the flexibility of configuring the external/custom libs at Runtime.
  5. It must be possible to change and pass the test environment data through command without making any changes at script level 
  6. The plugin should generate meaningful reports (or there must be some other possibility to generate these reports).

Step by Step to integrate Jmeter scripts (*.jmx) with Maven build.

Step 1: Create a maven project and place all the *.jmx files under src/test/jmeter

Step 2: Define the jmeter-maven-plugin in pom.xml file. Below is the sample pom.xml file for reference. 

<?xml version=â1.0â³ encoding=âUTF-8â³?>
<project xmlns=ââ³

jmeter-maven-plugin have multiple sections of goals and configurations in it and each one serves the unique purpose. Lets go in details about each goal and configuration defined.

configure : Generates JMeter configuration requires for script execution.

It do the following actions as part of goal.

  • Configuring JMeter artifacts
  • Copying extensions to jmeter/lib/ext
  • Copying junit libraries to jmeter/lib/junit
  • Copying test plan libraries jmeter/lib
  • Configuring JMeter properties

jmeter : Runs the JMeter tests defined in each *jmx file. We can also define the JVM properties incase of large value of test execution

results : Fails the build on errors in test based on defined error condition . Can be used in different ways based on the need. 

output :

Step 3: The Maven properties can be passed to JMeter via the userProperties option. Inside a JMeter test, you can then access the properties using the function ${__P(propertyName)}. This avoids the change of environment and other common data every time at scripts level and make us to define at runtime. 

*Note: This section is optional can be defined based on project need.

Step 4: Any external libraries used as part of test execution can be defined at jmeterExtensions section which allows users to download the libs from maven or any other custom repo.

Finally we are ready to execute the JMeter scripts by using maven command â¦. Below are few commands for reference

mvn clean verify 
mvn clean verify -Psample -Dservice.contextRoot=/search -Dservice.protocol=https -DrampUp=1 -DnumberOfThreads=1 -DnumberOfLoops=1

Final Output:



We use cookies and other technologies to improve your experience on our website and to analyze our traffic. By browsing our website, you consent to our use of cookies and other tracking technologies.

Accept cookies and close this message