Jmeter 3.0 can't generate the ANT HTML report

2019-08-02 09:25发布

问题:

I am on the verge of pulling all my hair out, someone please help me..

I am using JMeter 3.0 and am trying to generate the dashboard report from my jtl files, but I get the error -

result.jtl' does not contain the field names header, ensure the jmeter.save.saveservice.* properties are the same as when the CSV file was created or the file may be read incorrectly

my user.properites file contains -

jmeter.save.saveservice.output_format=csv
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.response_code=true
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.timestamp_format=ms
jmeter.save.saveservice.timestamp_format=yyyy-MM-dd HH:mm:ss
jmeter.save.saveservice.print_field_names=true

these values are the same in the jmeter.properties file as well, just to ensure I haven't lost anything...

I really can't work out why I can't get the jtl to include the headers, I have followed every guide I can find, and I seem to be doing it right..

Can someone point to me what I am missing, or include a zipped version of their jmeter with it all working that I can try and point my ant project to?

Hope someone can help.

回答1:

Double check <jmeter> section of your build.xml file. Default JMeter Ant Task assumes XML out put format for .jtl result files so if you have the following line:

<property name="jmeter.save.saveservice.output_format" value="xml"/>

just comment it out or delete it and your issue should be resolved.

I don't think JMeter Ant Task respects overrides via user.properties file, it is better to use jmeterproperties attribute or explicitly specify the relevant configuration in the Ant build file like:

<target name="test">
    <jmeter
        jmeterhome="${jmeter.home}"
        testplan ="${testpath}/${test}.jmx"
        resultlog="${testpath}/${test}.jtl">

        <property name="jmeter.save.saveservice.output_format" value="csv"/>
        <property name="jmeter.save.saveservice.print_field_names" value="true"/>
        <property name="jmeter.save.saveservice.timestamp_format" value="ms"/>
        <!--etc.-->
    </jmeter>
</target>

I would also recommend choosing one of jmeter.save.saveservice.timestamp_format properties (either ms or yyyy-MM-dd HH:mm:ss as it might cause problems with the dashboard generation), having duplicate property names with different values is not a very good practice.

See Five Ways To Launch a JMeter Test without Using the JMeter GUI article for more information on running JMeter tests via Ant task and other ways of kicking off a JMeter test



回答2:

I had noticed before you posted, but it is correct, the XML type was hardcoded in the build.xml, now I have changed that, all is working :)