我们可以使用Maven-jmeter插件自动生成jmeter仪表板报告,无需任何手动命令

问题描述 投票:0回答:2

我正在尝试从maven生成jmeter仪表板报告。但是为了生成jmeter仪表板报告,我们必须发出命令,

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

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

maven jmeter jmeter-maven-plugin
2个回答
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文章


0
投票

使用最新版本的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>
© www.soinside.com 2019 - 2024. All rights reserved.