2016-11-04 149 views
1

我無法使用的JMeter Maven的插件版本2.0.3,產生了對JMeter的3.0報告儀表板。我加入了和行家的JMeter在我的POM添加jmeter.save.saveservice性能下配置插件,但我得到「保證jmeter.save.saveservice。*屬性是相同的創建或CSV文件時,文件可能會被讀當我嘗試在執行後創建報告儀表板時出現「錯誤」錯誤。如何配置的JMeter的Maven插件生成的JMeter 3.0報告儀表板

我還添加了Jmeter.properties和user.properties在我的src /測試/ JMeter的文件夾,我看到這些屬性添加到這些文件在我的目標文件夾執行之後。

可以有些請告訴我POM應該如何使我們可以JMeter的3.0自動創建報告儀表板。

感謝

+0

支持,這將是在JMeter的,Maven的插件的下一個版本:https://github.com/jmeter-maven-plugin/jmeter-maven-plugin/issues/208 – Ardesco

回答

2

以下是具體步驟 -

  • 複製report-templatereportgenerator.reporties從JMeter的bin目錄,並將其保存在src/test/resources文件夾
  • 在你的POM中添加maven-antrun-plugin如下 -

<plugin> 
 
<artifactId>maven-antrun-plugin</artifactId> 
 
    <executions> 
 
    <execution> 
 
    <phase>pre-site</phase> 
 
    <configuration> 
 
     <tasks> 
 
     <mkdir dir="${basedir}/target/jmeter/results/dashboard" /> 
 
           <copy file="${basedir}/src/test/resources/reportgenerator.properties" 
 
\t \t \t \t \t \t \t \t \t 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>

運行的負載測試後,您可以執行mvn pre-site,它會生成測試JMeter的儀表板下方target\jmeter\results\dashboard

參考 - http://www.testautomationguru.com/jmeter-continuous-performance-testing-jmeter-maven/

一些事情 - 我不使用maven jmeter analysis因爲HTML儀表盤比這更好。因此,我以csv格式生成測試結果,這比xml資源更少。我用下面的shell腳本標記CI工作作爲測試失敗運行測試和生成報告後喚醒失敗 -

if grep false ${WORKSPACE}/prototype/target/jmeter/results/TestPlanNew.jtl; then 
echo "Test Failures!!! please check "${WORKSPACE}/prototype/target/jmeter/results/TestPlanNew.jtl" file" 
exit 1 
fi 
0

我想建議修改/添加到@塔倫的答案,因爲我得到了以下運行時出錯mvn pre-site

[java] An error occurred: Cannot read test results file :.../target/jmeter/results/*.jtl 

它必須使用通配符作爲結果文件名。如果您需要.jtl文件的動態文件名,那麼您也可以複製該文件併爲其指定一個靜態名稱。例如,通過包括以下<copy>塊分成<tasks>

<mkdir dir="${basedir}/target/jmeter/results/tmp" /> 
<copy todir="${basedir}/target/jmeter/results/tmp"> 
    <fileset dir="${basedir}/target/jmeter/results/" > 
     <include name="**/*.jtl"/> 
    </fileset> 
    <globmapper from="*" to="result.jtl" /> 
</copy> 

,並相應地爲-g參數調整值到

<arg value="${basedir}/target/jmeter/results/tmp/result.jtl" /> 

最後,後還包括一個org.slf4j:slf4j-simple:1.7.21依賴性(版本可以隨時間變化)爲JMeter(3.1),它工作並按預期生成HTML儀表板。

0

使用plugin將默認配置來產生的最後一個版本。

樣品POM。XML:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.foo</groupId> 
    <artifactId>test</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>training-project</name> 
    <url>http://maven.apache.org</url> 
    <dependencies> 
    </dependencies> 
    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
    <build> 
     <plugins> 
      <plugin> 
       <groupId>com.lazerycode.jmeter</groupId> 
       <artifactId>jmeter-maven-plugin</artifactId> 
       <version>2.6.0</version> 
       <executions> 
        <execution> 
         <id>jmeter-tests</id> 
         <goals> 
          <goal>jmeter</goal> 
         </goals> 
        </execution> 
        <execution> 
         <id>jmeter-tests2</id> 
         <goals> 
          <goal>results</goal> 
         </goals> 
        </execution> 
       </executions> 
       <configuration> 
        <generateReports>true</generateReports> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 

</project>