0% found this document useful (0 votes)
483 views

Generate HTML Report in J Meter

This document describes how to generate an HTML report from a JMeter test plan using Apache Ant. It provides prerequisites including downloading Apache Ant, AntJmeter.jar, and ensuring Java JDK is installed. It then details composing an Ant build file to run the JMeter test plan, generate an XML results file, and transform it to an HTML report using XSLT. A batch script is also composed to set environment variables and run the Ant target which executes the full process of running the test plan and generating the report.

Uploaded by

Thanh Chuong
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
483 views

Generate HTML Report in J Meter

This document describes how to generate an HTML report from a JMeter test plan using Apache Ant. It provides prerequisites including downloading Apache Ant, AntJmeter.jar, and ensuring Java JDK is installed. It then details composing an Ant build file to run the JMeter test plan, generate an XML results file, and transform it to an HTML report using XSLT. A batch script is also composed to set environment variables and run the Ant target which executes the full process of running the test plan and generating the report.

Uploaded by

Thanh Chuong
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

0

Generate HTML report in


JMeter

Author: Thanh Chuong

Generate HTML report in JMeter

TABLE OF CONTENTS
1

Purpose............................................2

Prerequisites......................................3

2.1

Apache Ant........................................................................................................................ 3

2.2

AntJmeter.jar..................................................................................................................... 4

2.3

Java JDK............................................................................................................................ 4

Run Jmter test plan using Ant......................6

3.1

Compose Ant build file.....................................................................................................6

3.2

Compose batch script......................................................................................................9

3.3

Run test plan..................................................................................................................... 9

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

PURPOSE
As we already know, when we run Jmeter as UI, it uses listener to collect information and generate
result in really cool, readable format. But when its run in console mode (in other to execute test
plans in a CI environment such as Team City, Bamboo), it just generate a raw report in jtl
extension file (XML format), its so hard to read, analyze result. This document will provide you the
way to generate the graphical Jmeter report in HTML format.

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

PREREQUISITES

Apache Ant
Its Java-based build tool, will be used to invoke JMeter, render HTML report at the end of test-run.
-

Download Apache Ant at : http://ant.apache.org/bindownload.cgi


Create ANT_HOME variable in the environment variable

Update PATH variable, append ANT bin folder - %ANT_HOME%\bin, so that you can run
Ants command everywhere

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

AntJmeter.jar
Will be used for Ant task for automating running JMeter test plans. It uses XSLT to transform JTL
extension file report into HTML report. Its has been stored in JMETER/extras folder.

Java JDK
-

Used for Apache Ant.


Make sure JDK is installed, and JAVA_HOME variable is added as Windows environment
variable

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

RUN JMTER TEST PLAN USING


ANT
Compose Ant build file
Prepare your ant build file (build.xml) with the following content
<?xml version="1.0"?>
<project name="ant-jmeter" default="all">
<description>
</description>
<property environment="env"/>
<property name="testpath" value="${user.dir}"/>
<property name="jmeter.home" value="${env.JMETER_HOME}"/>
<property name="jmeter.extras" value="${env.JMETER_EXTRAS}"/>
<property name="report.title" value="Load Test Results"/>
<property name="test" value="Test"/>
<property name="show-data" value="n"/>
<property name="format" value="2.1"/>
<condition property="style_version" value="">
<equals arg1="${format}" arg2="2.0"/>
</condition>
<condition property="style_version" value="_21">
<equals arg1="${format}" arg2="2.1"/>
</condition>
<condition property="funcMode">
<equals arg1="${show-data}" arg2="y"/>
</condition>

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

<condition property="funcMode" value="false">


<not>
<equals arg1="${show-data}" arg2="y"/>
</not>
</condition>
<path id="jmeter.classpath">
<fileset dir="${jmeter.extras}" includes="ant-jmeter*.jar">
</fileset>
</path>
<taskdef
name="jmeter"
classpathref="jmeter.classpath"
classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>
<target name="all" depends="run,report"/>
<target name="run">
<echo>funcMode = ${funcMode}</echo>
<delete file="${testpath}/${test}.html"/>
<delete file="${testpath}/${test}.jtl"/>
<jmeter
jmeterhome="${jmeter.home}"
testplan ="${testpath}/${test}.jmx"
resultlog="${testpath}/${test}.jtl">
<property name="jmeter.save.saveservice.output_format" value="xml"/>
<property name="jmeter.save.saveservice.assertion_results" value="all"/>
<property name="jmeter.save.saveservice.bytes" value="true"/>
<property name="file_format.testlog" value="${format}"/>
<property name="jmeter.save.saveservice.response_data.on_error" value="$
{funcMode}"/>

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter


</jmeter>
</target>
<property name="lib.dir" value="${jmeter.home}/lib"/>
<path id="xslt.classpath">
<fileset dir="${lib.dir}" includes="xalan*.jar"/>
<fileset dir="${lib.dir}" includes="serializer*.jar"/>
</path>
<target name="report" depends="xslt-report,copy-images">
<echo>Report generated at ${report.datestamp}</echo>
</target>
<target name="xslt-report" >
<tstamp><format property="report.datestamp" pattern="yyyy/MM/dd
HH:mm"/></tstamp>
<xslt
classpathref="xslt.classpath"
force="true"
in="${testpath}/${test}.jtl"
out="${testpath}/${test}.html"
style="${jmeter.extras}/jmeter-results-detail-report${style_version}.xsl">
<param name="showData" expression="${show-data}"/>
<param name="titleReport" expression="${report.title}"/>
<param name="dateReport" expression="${report.datestamp}"/>
</xslt>
</target>
<target name="copy-images" depends="verify-images" unless="samepath">
<copy file="${jmeter.extras}/expand.png" tofile="${testpath}/expand.png"/>
<copy file="${jmeter.extras}/collapse.png" tofile="${testpath}/collapse.png"/>
</target>
<target name="verify-images">

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter


<condition property="samepath">
<equals arg1="${testpath}" arg2="{jmeter.home}/extras" />
</condition>
</target>
</project>

Compose batch script


-

Prepare your batch script (runTestPlan.bat) with the following content:

set JMETER_HOME=f:\Project\apache-jmeter-2.13\
set JMETER_EXTRAS=%JMETER_HOME%\extras
set REPORT_TITLE="Prevalent API test"
ant -Dtest=login -Dreport.title=%REPORT_TITLE%

Run test plan


-

Put build.xml and runTestPlan.bat in the same place.


Run runTestPlan.bat
You can receive the html report at the end of test run

RUN JMTER TEST PLAN USING ANT

Generate HTML report in JMeter

RUN JMTER TEST PLAN USING ANT

10

You might also like