You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

jmeter-maven-plugin生成HTML报告与当前CSV数据不符问题咨询

问题原因

jmeter-maven-plugin默认不会自动清理历史执行的报告目录和残留文件,新生成的报告没有覆盖旧文件,因此展示的是首次执行的旧数据。你需要在插件的<configuration>节点补充以下配置项:

  • 开启执行前删除历史结果目录:<deleteResultsDirectoryBeforeRun>true</deleteResultsDirectoryBeforeRun>,避免旧的结果数据被复用
  • 开启执行前删除历史报告目录:<clearReportsDirectoryBeforeRun>true</clearReportsDirectoryBeforeRun>,直接清空旧的HTML报告文件
  • 开启结果文件覆盖规则:<overwriteResults>true</overwriteResults>,确保新的测试结果可以覆盖旧的结果文件

修改后完整配置示例

<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>
                    <csvPath>${basedir}/src/test/resources/testData.csv</csvPath>
                </propertiesUser>
                <generateReports>true</generateReports>
                <!-- 新增的3项配置 -->
                <deleteResultsDirectoryBeforeRun>true</deleteResultsDirectoryBeforeRun>
                <clearReportsDirectoryBeforeRun>true</clearReportsDirectoryBeforeRun>
                <overwriteResults>true</overwriteResults>
            </configuration>
        </plugin>
    </plugins>
</build>

补充配置后重新执行测试即可生成对应最新结果的HTML报告,也可在执行测试命令时带上mvn clean参数,强制清理整个构建目录后再执行测试,进一步避免旧文件残留。

内容的提问来源于stack exchange,提问作者QA-Palash

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.09 20:39:02