Maven is more of a Project management tool, which follows a standard project structure to ease the development process. Moreover, it takes care of setting up JMeter with all the dependencies to run the test.
How to create a maven project and pom.xml file?
- Create a folder structure as below.
JMeterWsdlProject
——Src
———-Test
————–JMeter
—————– Demo-Test.jmx
——pom.xml
- JMeterWsdlProject: This is JMeter project name and you can provide any name
- Src: This is the source folder, it should be of the same name
- Test: It should be of the same name
- JMeter: You can change this folder name
- Demo-Test.jmx: This is a JMeter test script project
- XML: This is maven file, it should be at the root folder. Pom.xml file contains below code:
<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>jmeter-maven-test</groupId>
<artifactId>jmeter-maven-test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jmeter-maven-test</name>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
How to execute a JMeter test using maven?
- Open command prompt
- Go to the root of the project of maven JMeter
- Run below command
- You should see below screen where mvn starts downloading all required dependencies and then executes the test
- After executing you should see the report under “target\jmeter\report”
- Open HTML file you should see a report like below:
You may also like: How to Setup Maven on Windows?
Recent Comments