JMeter maven 插件 - 自定义 reportgenerator.properties

JMeter maven plugin - Customize reportgenerator.properties

当我使用 JMeter Maven 插件时,运行 mvn jmeter:configure 它会自动创建一个默认的 bin/reportgenerator.properties 文件。

如何自定义此文件?有没有办法在 jmeter-maven 插件配置中指定一些属性,以便我可以设置,例如 report_title?

参见:https://jmeter.apache.org/usermanual/generating-dashboard.html

添加到pom.xml

<jmeter.reportgenerator.report_title>Shantonu Example</jmeter.reportgenerator.report_title>

参见Modifying Properties chapter of JMeter Maven Plugin wiki

您需要将以下块添加到您的 <plugin> 部分:

<configuration>
    <propertiesUser>
        <jmeter.reportgenerator.report_title>your-custom-title</jmeter.reportgenerator.report_title>
    </propertiesUser>
</configuration>

完整 pom.xml 以防万一:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>jmeter-maven</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.lazerycode.jmeter</groupId>
                <artifactId>jmeter-maven-plugin</artifactId>
                <version>3.4.0</version>
                <executions>
                    <!-- Generate JMeter configuration -->
                    <execution>
                        <id>configuration</id>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                    <!-- Run JMeter tests -->
                    <execution>
                        <id>jmeter-tests</id>
                        <goals>
                            <goal>jmeter</goal>
                        </goals>
                    </execution>
                    <!-- Fail build on errors in test -->
                    <execution>
                        <id>jmeter-check-results</id>
                        <goals>
                            <goal>results</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <propertiesUser>
                        <jmeter.reportgenerator.report_title>your-custom-title</jmeter.reportgenerator.report_title>
                    </propertiesUser>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

更多信息:How to Use the JMeter Maven Plugin