#TECH

Automating JMETER Scripts With MAVEN and JENKINS

Before starting with the integration of Jmeter scripts with Mvn and Jenkins we should know what is a jmeter, jenkins and maven.

What is jmeter?

Jmeter is an Open Source performance testing tool . It is 100% Java application. It is designed to cover categories of tests like load, functional, performance, regression, etc.,

Whats is jenkins?

Jenkins is an open source continuous integration (CI) tool written in Java. It provides continuous integration services for software development. It is a server-based system running in a servlet container such as Apache Tomcat.

What is maven?

Maven is a build automation tool used primarily for Java projects. Maven addresses two aspects of building software: First, it describes how software is built, and second, it describes its dependencies.

Step by Step to integrate Jmeter(Performance Tool) with Maven build.

Step 1:

You should be having jmeter test .jmx file and that test must be placed in the folder /src/test/jmeter

Step 2:

Create a POM file and place it along with /src folder.

Below is an Example of a POM.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/6.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>1.10.1</version>
            <executions>
               <execution>
                  <id>jmeter-tests</id>
                  <phase>verify</phase>
                  <goals>
                     <goal>jmeter</goal>
                  </goals>
                  <configuration>
                     <testFilesIncluded>
                        <jMeterTestFile>${JmeterTestFile}.jmx</jMeterTestFile>
                     </testFilesIncluded>
                     <testResultsTimestamp>false</testResultsTimestamp>
                     <propertiesUser>
                        <Threadcount>${Threadcount}</Threadcount>
                        <Loopcount>${Loopcount}</Loopcount>
                        <Rampup>${RampUp}</Rampup>
                     </propertiesUser>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>
</project>

 

Step 3:

The Maven properties are passed to JMeter via the userProperties option. Inside a JMeter test, you can then access the properties using the function ${__P(propertyName)}.

Eg: <stringProp name=”LoopController.loops”>${__P(Loopcount,3)}</stringProp>

Step 4:

To run jmeter test through maven, use below command in command prompt

mvn -DJmeterTestFile=Click_link_through -DRampUp=10 -DLoopcount=2 -DThreadcount=3 verify

Step 5:

Jenkins Configurations

Jenkins provides the great “Performance” plugin (https://wiki.jenkins-

ci.org/display/JENKINS/Performance+Plugin) for reporting JMeter results.

 

jmeter performance report

jmeter performance report

 

 

running the test …

running the test …

 

 

 

 

 

 

 

 

 

The build overview page shows the trends for throughput, error rates and response timings for all JMeter tests.

response timings for all JMeter tests

 

 

 

 

 

 

 

 

 

 

The Performance Report shows some more details and detailed numbers for each test

more details and detailed numbers for each test

 

 

 

 

 

 

 

 

 

 

And of course you can drill down to every single test plan.