1
votes

I am unable to generate the report Dashboard for Jmeter 3.0 by using Jmeter-maven-plugin version 2.0.3. I added the and added jmeter.save.saveservice properties in my pom under configuration in Jmeter maven plugin but I get "ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly" error when I try to create report Dashboard after execution.

I also added Jmeter.properties and user.properties in my src/test/jmeter folder and I see these properties are added to these files in my target folder after execution.

Can Some please tell me how the pom should be so that we can create the report Dashboard automatically for Jmeter 3.0.

Thanks

4
Support for this will be in the next release of the jmeter-maven-plugin: github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/208Ardesco

4 Answers

3
votes

Here are the steps -

  • Copy report-template reportgenerator.reporties from jmeter bin directory and keep it in src/test/resourcesfolder
  • Add maven-antrun-plugin in your pom as following -

<plugin>
 <artifactId>maven-antrun-plugin</artifactId>
  <executions>
   <execution>
    <phase>pre-site</phase>
     <configuration>
      <tasks>
       <mkdir dir="${basedir}/target/jmeter/results/dashboard" />
                                <copy file="${basedir}/src/test/resources/reportgenerator.properties" 
									  tofile="${basedir}/target/jmeter/bin/reportgenerator.properties" />
                                <copy todir="${basedir}/target/jmeter/bin/report-template">
                                    <fileset dir="${basedir}/src/test/resources/report-template" />
                                </copy>
                                <java jar="${basedir}/target/jmeter/bin/ApacheJMeter-3.0.jar" fork="true">
                                    <arg value="-g" />
                                    <arg value="${basedir}/target/jmeter/results/*.jtl" />
                                    <arg value="-o" />
                                    <arg value="${basedir}/target/jmeter/results/dashboard/" />
                                </java>
       </tasks>
      </configuration>
     <goals>
    <goal>run</goal>
   </goals>
</execution>
   </executions>
 </plugin>

After running load test you can execute mvn pre-site and it would generate test JMeter dashboard under target\jmeter\results\dashboard

Reference - http://www.testautomationguru.com/jmeter-continuous-performance-testing-jmeter-maven/

Few more things - I don't use maven jmeter analysis since html dashboard is far better than this. Hence I generate test results in csv format which is less resource intense than xml. I use following shell script to mark CI job as failure in the wake of test failures after running test and generating report -

if grep false ${WORKSPACE}/prototype/target/jmeter/results/TestPlanNew.jtl; then
echo "Test Failures!!! please check "${WORKSPACE}/prototype/target/jmeter/results/TestPlanNew.jtl" file"
exit 1
fi
1
votes

I want to suggest a modification/addition to @Tarun's answer, as I was getting the following error when running mvn pre-site:

[java] An error occurred: Cannot read test results file :.../target/jmeter/results/*.jtl

It had to do with using a wildcard for the result filename. If you require a dynamic filename for the .jtl file, then you can also copy the file and give it a static name. For example, via including the following <copy> block into <tasks>:

<mkdir dir="${basedir}/target/jmeter/results/tmp" />
<copy todir="${basedir}/target/jmeter/results/tmp">
    <fileset dir="${basedir}/target/jmeter/results/" >
        <include name="**/*.jtl"/>
    </fileset>
    <globmapper from="*" to="result.jtl" />
</copy>

and adjusting the value for the -g argument accordingly to

<arg value="${basedir}/target/jmeter/results/tmp/result.jtl" />

Finally, after also including a org.slf4j:slf4j-simple:1.7.21 dependency (version may vary over time) for JMeter (3.1), it worked and generated the HTML Dashboard as expected.

0
votes

Using last version of the plugin it will be generated by default configuration.

Sample pom.xml:

<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.foo</groupId>
    <artifactId>test</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>training-project</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>2.6.0</version>
                <executions>
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jmeter-tests2</id>
                        <goals>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <generateReports>true</generateReports>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
0
votes

Maven 2.3 version will generate jtl report which can be processed by ant.

<tasks>
<delete dir="${basedir}/target/jmeter/results/dashboard"/>
<mkdir dir="${basedir}/target/jmeter/results/dashboard" />
<copy file="${basedir}/src/test/resources/reportgenerator.properties"
tofile="${basedir}/target/jmeter/bin/reportgenerator.properties" />
<copy todir="${basedir}/target/jmeter/bin/report-template">
<fileset dir="${basedir}/src/test/resources/report-template" />
</copy>                                
<mkdir dir="${basedir}/target/jmeter/results/tmp" />
<copy todir="${basedir}/target/jmeter/results/tmp">
 <fileset dir="${basedir}/target/jmeter/results/" >
 <include name="**/*.jtl"/>
</fileset>
<globmapper from="*" to="result.jtl" />
</copy>                                
 <java jar="${basedir}/target/jmeter/bin/ApacheJMeter-3.3.jar" fork="true">
 <arg value="-g" />
 <arg value="${basedir}/target/jmeter/results/tmp/result.jtl" />
<arg value="-o" />
<arg value="${basedir}/target/jmeter/results/dashboard/" />
</java>
</tasks>