2015-09-14 74 views
0

我一直在更新我的Jmeter從2.9到2.13。我通常使用ant build和xslt來生成html報告。這裏是我的螞蟻xml腳本:Jmeter Xslt測試報告「嚴重錯誤!內容在prolog中不被允許」。

<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet type="text/xsl" href="ballot.xsl"?> 


<project default="all"> 
    <!-- Define an environment variable pointing to JMETER folder or change this --> 
    <property environment="env"/> 
<!-- <property name="jmeter-home" location="${env.JMETER_DIR}"/>--> 
<property name="jmeter-home" location="C:\apache-jmeter-2.13"/> 

    <!-- ant-jmeter.jar comes with jmeter, be sure this is the release you have --> 
    <path id="ant.jmeter.classpath"> 
    <pathelement 
     location="${jmeter-home}/extras/ant-jmeter-1.1.1.jar" /> 
    </path> 
    <taskdef 
    name="jmeter" 
    classname="org.programmerplanet.ant.taskdefs.jmeter.JMeterTask" 
    classpathref="ant.jmeter.classpath" /> 
    <target name="clean"> 
    <delete dir="results2"/> 
    <delete file="jmeter.log"/> 
    <mkdir dir="results2/jtl"/> 
    <mkdir dir="results2/html"/> 
    </target> 
    <target name="test" depends="clean"> 
    <jmeter 
     jmeterhome="${jmeter-home}" 
     resultlogdir="results2/jtl"> 
     <testplans dir="IAM_jmeter" includes="*.jmx"/> 
    </jmeter> 
    </target> 
    <!-- This is not needed for the plugin, but it produces a nice html report 
     which can be saved usin hudson's archive artifact feature --> 
    <target name="report" depends="test"> 
    <xslt 
     basedir="results2/jtl" 
     destdir="results2/html" 
     includes="*.jtl" 
     style="${jmeter-home}/extras/jmeter-results-detail-report_21.xsl"/> 
    </target> 

    <target name="all" depends="test, report"/> 
</project> 

它與jmeter 2.9一起工作。但是當我更新到2.13米時,它會產生一個錯誤。這裏是錯誤信息:

[xslt] Transforming into C:\Users\Administrator\Downloads\workspace\IAM-JmeterTest-Rest\results2\html 
    [xslt] Processing C:\Users\Administrator\Downloads\workspace\IAM-JmeterTest-Rest\results2\jtl\IAM_Jmeter.jtl to C:\Users\Administrator\Downloads\workspace\IAM-JmeterTest-Rest\results2\html\IAM_Jmeter.html 
    [xslt] Loading stylesheet C:\apache-jmeter-2.13\extras\jmeter-results-detail-report_21.xsl 
    [xslt] C:\Users\Administrator\Downloads\workspace\IAM-JmeterTest-Rest\results2\jtl\IAM_Jmeter.jtl:1:1: Fatal Error! Content is not allowed in prolog. 
    [xslt] Failed to process null 

任何想法爲什麼? 感謝您的關注。

回答

1

我的期望是,這是由於.jtl文件的CSV格式,而對於成功的XSLT轉換,它需要是XML。

您需要「告訴」JMeter以XML格式存儲其結果。要做到這一點添加以下行來「測試」目標:

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

所以整個目標將是看看:

<target name="test" depends="clean"> 
    <jmeter 
      jmeterhome="${jmeter-home}" 
      resultlogdir="results2/jtl"> 
     <property name="jmeter.save.saveservice.output_format" value="xml"/> 
     <testplans dir="IAM_jmeter" includes="*.jmx"/> 
    </jmeter> 
</target> 

另一種選擇是添加以下行user.properties文件(在你的$的/ bin文件夾生活{JMeter的家庭}

jmeter.save.saveservice.output_format=xml 

Apache JMeter Properties Customization Guide關於JMeter的屬性和設置的方式的詳細信息重寫它們。

相關問題