【问题标题】:Can we automatically generate jmeter dashboard report with Maven-jmeter plugin with out any manual command我们可以在没有任何手动命令的情况下使用 Maven-jmeter 插件自动生成 jmeter 仪表板报告吗
【发布时间】:2016-06-13 06:47:32
【问题描述】:

我正在尝试从 maven 生成 jmeter 仪表板报告。但是要生成 jmeter 仪表板报告,我们必须触发一个命令,

jmeter -g /path/to/jtl/file -o /where/you/want/to/store/dashboard

但是使用 maven 我们可以做到这一点吗?我想要的是删除复制 csv 文件的所有手动过程并在 jmeter 的本地副本上运行命令。

【问题讨论】:

    标签: maven jmeter jmeter-maven-plugin


    【解决方案1】:

    您可以通过额外的Exec Maven Plugin 任务来完成,如下所示:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.5.0</version>
        <executions>
            <execution>
                <id>generate-report-dashboard</id>
                <phase>verify</phase>
                <goals>
                    <goal>exec</goal>
                </goals>
                <configuration>
                    <executable>java</executable>
                    <arguments>
                        <argument>-classpath</argument>
                        <argument>/path/to/ApacheJMeter.jar</argument>
                        <argument>org.apache.jmeter.NewDriver</argument>
                        <argument>-g</argument>
                        <argument>/path/to/results.jtl</argument>
                        <argument>-o</argument>
                        <argument>/path/to/report/folder<argument>
                    </arguments>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

    有关在不使用 GUI 的情况下启动 JMeter 测试的不同方式的更多信息,请参阅 Five Ways To Launch a JMeter Test without Using the JMeter GUI 文章

    【讨论】:

    • 感谢 Dmitri,您解决了我的一半问题,但是“Jmeter.jar 的路径”应该是什么。我可以将它定向到 maven 存储库吗?
    • 假设您的 Maven 项目在其类路径中有 JMeter jars,您可以使用以下内容:-classpath
    • 是的,当我提供本地 apachejmeter.jar(3.0 版)的绝对路径时,它起作用了。但是当我尝试给出相对路径时,maven总是下载2.13版本的jmeter。所以 Maven 构建失败了。我的 artifactId 应该是什么,这样它才能下载所有 jmeter 3.0 依赖项。或者我应该单独添加每个。
    • 我相信你应该问问 Maven JMeter 插件开发者,我对那个工件没有任何控制权
    • @Dimitri,是的,我应该这样做。谢谢。
    【解决方案2】:

    使用最新版本的jmeter-maven-plugin,默认配置会生成。

    使用 JMeter 3.3 的 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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-11
      • 2018-01-29
      • 1970-01-01
      • 1970-01-01
      • 2016-11-11
      • 1970-01-01
      • 1970-01-01
      • 2019-01-28
      相关资源
      最近更新 更多