2016-11-04 153 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>