Search code examples
jmeterjmeter-maven-plugin

How to avoid target folder update in maven folder structure


We have created a framework to run our jmeter script using maven folder structure. This framework will create a reporting for every run when we run the test using "mvn verify" command. We need to customize the report to include some more details, but every time when we run maven command, it download the jmeter resource and update target folder in the framework. Due to this, all over customization we will cleared and not able to create expected report. My POM look like below

<?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/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>2.4.0</version>
            <executions>
               <execution>
                  <id>jmeter-tests</id>
                  <phase>verify</phase>
                  <goals>
                     <goal>jmeter</goal>
                  </goals>
               </execution>
            </executions>
            <configuration>
               <generateReports>true</generateReports>
               <jMeterProcessJVMSettings>
                  <xms>1024</xms>
                  <xmx>1024</xmx>
                  <arguments>
                     <argument>-Xprof</argument>
                     <argument>-Xfuture</argument>
                  </arguments>
               </jMeterProcessJVMSettings>
               <propertiesUser>
                  <testdatafile>${testdatafile}</testdatafile>
                  <suite>${suite}</suite>
               </propertiesUser>
               <testFilesIncluded>
                  <jMeterTestFile>testplans/${jmxfile}</jMeterTestFile>
               </testFilesIncluded>
            </configuration>
         </plugin>
      </plugins>
   </build>
</project>

Any help to resolve issue is much appreciated.


Solution

  • As per Basic Configuration chapter

    The following properties files will be used if they are found in ${project.base.directory}/src/test/jmeter:

    • jmeter.properties
    • saveservice.properties
    • upgrade.properties
    • system.properties
    • user.properties
    • global.properties

    So you can just perform required configuration overrides in user.properties file and put the file to the folder where your JMeter .jmx script(s) live. Maven plugin will pick this up and override the relevant values


    Alternatively you can override any properties directly in your pom.xml file by specifying them under configuration/propertiesJMeter section.

    Below example tells JMeter to store results as xml and save response data:

    <propertiesJMeter>
        <jmeter.save.saveservice.output_format>xml</jmeter.save.saveservice.output_format>
        <jmeter.save.saveservice.response_data>true</jmeter.save.saveservice.response_data>
    </propertiesJMeter>
    

    Full pom.xml just in case:

    <?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/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>2.4.0</version>
                    <executions>
                        <execution>
                            <id>jmeter-tests</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>jmeter</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <!-- save response data -->
                        <propertiesJMeter>
                            <jmeter.save.saveservice.output_format>xml</jmeter.save.saveservice.output_format>
                            <jmeter.save.saveservice.response_data>true</jmeter.save.saveservice.response_data>
                        </propertiesJMeter>
                        <generateReports>true</generateReports>
                        <jMeterProcessJVMSettings>
                            <xms>1024</xms>
                            <xmx>1024</xmx>
                            <arguments>
                                <argument>-Xprof</argument>
                                <argument>-Xfuture</argument>
                            </arguments>
                        </jMeterProcessJVMSettings>
                        <propertiesUser>
                            <testdatafile>${testdatafile}</testdatafile>
                            <suite>${suite}</suite>
                        </propertiesUser>
                        <testFilesIncluded>
                            <jMeterTestFile>testplans/${jmxfile}</jMeterTestFile>
                        </testFilesIncluded>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    

    More information: