1

I am able to generate Jmeter dashboard report manually using this command jmeter -g /path/to/jtl/file -o /where/you/want/to/store/dashboard but I want to generate it through maven project.

Is there any way?

Below is the plugin ex:

<goals>
<goal>jmeter</goal>
</goals>
<configuration>
    <propertiesUser>
    <jmeter.save.saveservice.output_format>csv</jmeter.save.saveservice.output_format>
    <jmeter.save.saveservice.bytes>true</jmeter.save.saveservice.bytes>
    <jmeter.save.saveservice.label>true</jmeter.save.saveservice.label>
    <jmeter.save.saveservice.latency>true</jmeter.save.saveservice.latency>
    <jmeter.save.saveservice.response_code>true</jmeter.save.saveservice.response_code>
    <jmeter.save.saveservice.response_message>true</jmeter.save.saveservice.response_message>
    <jmeter.save.saveservice.successful>true</jmeter.save.saveservice.successful>
    <jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
    <jmeter.save.saveservice.thread_name>true</jmeter.save.saveservice.thread_name>
    <jmeter.save.saveservice.time>true</jmeter.save.saveservice.time></propertiesUser>
<propertiesSaveService>
    <output_format>csv</output_format>
</propertiesSaveService>
Atul Kumar
  • 73
  • 2
  • 11
  • Support for this will be in the next version of the meter-maven-plugin: https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/208 – Ardesco Feb 20 '17 at 14:17

2 Answers2

1

This is how I create the HTML report with mvn using mvn ant plugin.

I have my report-template and reportgenerator.properties under src/testresources.

    <plugins>
        <plugin>
            <groupId>com.lazerycode.jmeter</groupId>
            <artifactId>jmeter-maven-plugin</artifactId>
            <version>2.0.3</version>
            <configuration>
                <testResultsTimestamp>false</testResultsTimestamp>
                <propertiesUser>
                    <jmeter.save.saveservice.output_format>csv</jmeter.save.saveservice.output_format>
                    <jmeter.save.saveservice.bytes>true</jmeter.save.saveservice.bytes>
                    <jmeter.save.saveservice.label>true</jmeter.save.saveservice.label>
                    <jmeter.save.saveservice.latency>true</jmeter.save.saveservice.latency>
                    <jmeter.save.saveservice.response_code>true</jmeter.save.saveservice.response_code>
                    <jmeter.save.saveservice.response_message>true</jmeter.save.saveservice.response_message>
                    <jmeter.save.saveservice.successful>true</jmeter.save.saveservice.successful>
                    <jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
                    <jmeter.save.saveservice.thread_name>true</jmeter.save.saveservice.thread_name>
                    <jmeter.save.saveservice.time>true</jmeter.save.saveservice.time>
                </propertiesUser>
            </configuration>
            <executions>
                <execution>
                    <id>jmeter-tests</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>jmeter</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>verify</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>
    </plugins>
vins
  • 15,030
  • 3
  • 36
  • 47
  • thanks for the help. I tried this and now am getting below error: An error occurred: Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property [INFO] Executed tasks [java] Java Result: 1 – Atul Kumar Nov 13 '16 at 06:49
  • `csv` - check this. the new report format expects the output file to be in csv format – vins Nov 13 '16 at 23:55
0

First of all you will need to configure JMeter Maven Plugin to store the test results in the format, suitable for HTML Reporting dashboard generation, i.e. add the next few lines to your pom.xml file:

<jmeter.save.saveservice.output_format>csv</jmeter.save.saveservice.output_format>
<jmeter.save.saveservice.bytes>true</jmeter.save.saveservice.bytes>
<jmeter.save.saveservice.label>true</jmeter.save.saveservice.label>
<jmeter.save.saveservice.latency>true</jmeter.save.saveservice.latency>
<jmeter.save.saveservice.response_code>true</jmeter.save.saveservice.response_code>
<jmeter.save.saveservice.response_message>true</jmeter.save.saveservice.response_message>
<jmeter.save.saveservice.successful>true</jmeter.save.saveservice.successful>
<jmeter.save.saveservice.thread_counts>true</jmeter.save.saveservice.thread_counts>
<jmeter.save.saveservice.thread_name>true</jmeter.save.saveservice.thread_name>
<jmeter.save.saveservice.time>true</jmeter.save.saveservice.time>

I believe the most straightforward way would be using Exec Maven Plugin, something like:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>exec</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <executable>java</executable>
        <arguments>
            <argument>-jar</argument>
            <argument>${basedir}/target/jmeter/bin/ApacheJMeter-3.0.jar</argument>
            <argument>-g</argument>
            <argument>${basedir}/target/jmeter/results/${maven.build.timestamp}-example.jtl</argument>
            <argument>-o</argument>
            <argument>${basedir}/target/dashboard</argument>
        </arguments>
    </configuration>
</plugin>

You might need to copy reportgenerator.properties file and report-template folder to "target/jmeter/bin" directory of your Maven project (it will not survive "clean" phase) or duplicate the properties as it described in Adding Additional Properties To chapter.

See Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on different options of executing a JMeter test

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • thanks for the help. I tried this and now am getting below error: An error occurred: Report generation requires csv output format, check 'jmeter.save.saveservice.output_format' property [INFO] Executed tasks [java] Java Result: 1 – Atul Kumar Nov 13 '16 at 06:47
  • My expectation is that you either missed `csv` line or you are trying to append new CSV results to existing file in XML format – Dmitri T Nov 13 '16 at 10:55