1

I have a testing jmeter script that runs a single request for a REST service I had run

ant run 
generate-report

the report is successfully generated but it seems quite no descriptive enter image description here

I need the html to contain the json response payload. I am using this build.xml file

<?xml version="1.0"?>

TestAutomationGuru - Continuous Performance Testing Process

<!-- Read the test properties from build.propertis -->
<property file="build.properties" />

<!-- System & other ant properties -->
<property environment="env" />
<property name="jmeter.home" value="${env.JMETER_HOME}"/>
<property name="test.path" value="${basedir}/test"/>
<property name="test.name" value="test.jmx"/>
<property name="test.result.path" value="${basedir}/result"/>
<property name="test.result.log" value="${basedir}/log"/>
<property name="lib.dir" value="${basedir}/lib"/>

<!-- set classpath with the path containing jars -->
<path id="jmeter.classpath">
    <fileset dir="${lib.dir}">
            <include name="*.jar"/>
    </fileset>
</path>
<pathconvert pathsep=":"  property="jmeter.classpath" refid="jmeter.classpath"></pathconvert>

<!-- call all tasks in this sequence -->
<target name="all"
        depends="clean,show-test-properties,run,generate-report,generate-chart"/>

<!-- clean project by removing all the temp files -->
<target name="clean">
     <delete dir="${test.result.path}"/>
     <delete dir="${test.result.log}"/>
</target>

<!-- show test properties -->
<target name="show-test-properties">
    <echo>JMETER_HOME               : ${jmeter.home}</echo>
    <echo>TEST_PATH             : ${test.path}</echo>
    <echo>TEST_NAME             : ${test.name}</echo>
    <echo>THREADGROUP_COUNT         : ${threadgroup.count}</echo>
    <echo>THREADGROUP_RAMPUP            : ${threadgroup.rampup}</echo>
    <echo>THREADGROUP_DURATION      : ${threadgroup.duration}</echo>
</target>   

<!-- jmeter ant task -->
<taskdef
    name="jmeter"
    classpathref="jmeter.classpath"
    classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask"/>

<!-- To run jmeter test -->
<target name="run" depends="clean, show-test-properties">

    <!-- create dir -->
    <mkdir  dir="${test.result.path}"/>
    <mkdir  dir="${test.result.log}"/>

    <jmeter
        jmeterhome="${jmeter.home}"
        testplan ="${test.path}/${test.name}"
        resultlog="${test.result.path}/result.jtl"
        jmeterlogfile="${test.result.log}/jmeter.log"
        >
        <jvmarg value="-Xmx5120m"/> <!-- modify as you wish -->

        <!-- Force suitable defaults -->
        <property name="jmeter.save.saveservice.output_format" value="xml"/>
        <property name="jmeter.save.saveservice.assertion_results" value="all"/>
        <property name="jmeter.save.saveservice.thread_counts" value="true"/>
        <property name="jmeter.save.saveservice.bytes" value="true"/>
        <property name="jmeter.save.saveservice.response_data.on_error" value="true"/>
        <!-- values for UDV -->
        <property name="threadgroup.count" value="${threadgroup.count}"/>
        <property name="threadgroup.rampup" value="${threadgroup.rampup}"/>
        <property name="threadgroup.duration" value="${threadgroup.duration}"/>
    </jmeter>
</target>

<target name="generate-report">
    <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
    <copy file="${basedir}/src/expand.png" tofile="${test.result.path}/expand.png"/>
    <copy file="${basedir}/src/collapse.png" tofile="${test.result.path}/collapse.png"/>
    <xslt
        classpathref="jmeter.classpath"
        force="true"
        in="${test.result.path}/result.jtl"
        out="${test.result.path}/result.html"
        style="${basedir}/src/jmeter-results-detail-report_21.xsl">
        <param name="showData" expression="true"/>
        <param name="titleReport" expression="CPT--Aggregate-Report"/>
        <param name="dateReport" expression="${report.datestamp}"/>
    </xslt>
    <echo>Report generated at ${report.datestamp}</echo>
</target>   

<taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml">
    <classpath>
        <pathelement location="${lib.dir}/ant-contrib-1.0b3.jar"/>
    </classpath>
</taskdef>
<target name="generate-chart">
        <!-- copy this jar to the JMETER_HOME/lib/ext folder -->
        <copy file="${lib.dir}/CMDRunner.jar" tofile="${jmeter.home}/lib/ext/CMDRunner.jar"/>
        <ac:for param="reportType" list="LatenciesOverTime,TimesVsThreads,ResponseTimesOverTime,ThreadsStateOverTime,TransactionsPerSecond,ResponseTimesPercentiles,ResponseTimesDistribution">
              <sequential>
                    <java  jar="${jmeter.home}/lib/ext/CMDRunner.jar" fork="true">
                          <arg value="--tool"/>
                          <arg value="Reporter"/>
                          <arg value="--generate-png"/>
                          <arg value="${test.result.path}/@{reportType}.png"/>
                          <arg value="--input-jtl"/>
                          <arg value="${test.result.path}/result.jtl"/>
                          <arg value="--plugin-type"/>
                          <arg value="@{reportType}"/>
                          <arg value="--aggregate-rows"/>
                          <arg value="yes"/>
                          <arg value="--limit-rows"/>
                          <arg value="20"/>                         
                          <arg value="--width"/>
                          <arg value="800"/>
                          <arg value="--height"/>
                          <arg value="600"/>
                    </java>
              </sequential>
        </ac:for>
</target>

here you can get build.xml file https://gist.github.com/Ticlla/fbd60a527105d4eb9e07f98b83ae5705

  • means you wanted to add more descriptive report by adding response payload, is I'm interpreting you correctly? – NarendraC Aug 4 '16 at 5:53
  • yeah I want the report to contain the json response payload. – Alcides Ticlla Aug 4 '16 at 13:55
  • from my understanding is that build.xml need to be modified so that the .html report contains the json payload but I may be wrong. – Alcides Ticlla Aug 4 '16 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.