1

我无法使用 Jmeter-maven-plugin 2.0.3 版为 Jmeter 3.0 生成报告仪表板。我在 Jmeter maven 插件的配置下的 pom 中添加并添加了 jmeter.save.saveservice 属性,但我得到“确保 jmeter.save.saveservice.* 属性与创建 CSV 文件时相同或可以读取文件执行后尝试创建报告仪表板时出现错误”错误。

我还在我的 src/test/jmeter 文件夹中添加了 Jmeter.properties 和 user.properties,我看到这些属性在执行后被添加到我的目标文件夹中的这些文件中。

有人可以告诉我 pom 应该如何,以便我们可以为 Jmeter 3.0 自动创建报告仪表板。

谢谢

4

4 回答 4

3

以下是步骤-

  • report-template reportgenerator.reporties从 jmeter bin 目录复制并保存在src/test/resources文件夹中
  • 添加maven-antrun-plugin你的pom如下 -

<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" 
									  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 分析,因为 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
于 2017-01-04T10:18:34.687 回答
1

我想建议对@Tarun 的答案进行修改/添加,因为我在运行时遇到以下错误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.21JMeter (3.1) 的依赖项(版本可能随时间变化)之后,它按预期工作并生成了 HTML 仪表板。

于 2017-01-17T11:07:28.273 回答
0

Maven 2.3 版本会生成 ant 可以处理的 jtl 报告。

<tasks>
<delete dir="${basedir}/target/jmeter/results/dashboard"/>
<mkdir dir="${basedir}/target/jmeter/results/dashboard" />
<copy file="${basedir}/src/test/resources/reportgenerator.properties"
tofile="${basedir}/target/jmeter/bin/reportgenerator.properties" />
<copy todir="${basedir}/target/jmeter/bin/report-template">
<fileset dir="${basedir}/src/test/resources/report-template" />
</copy>                                
<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>                                
 <java jar="${basedir}/target/jmeter/bin/ApacheJMeter-3.3.jar" fork="true">
 <arg value="-g" />
 <arg value="${basedir}/target/jmeter/results/tmp/result.jtl" />
<arg value="-o" />
<arg value="${basedir}/target/jmeter/results/dashboard/" />
</java>
</tasks>
于 2019-06-27T03:23:02.677 回答
0

使用插件的最新版本,它将由默认配置生成。

示例 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>
于 2017-12-30T21:02:28.817 回答