我们已经创建了一个框架来使用maven文件夹结构来运行我们的jmeter脚本。当我们使用" mvn verify"运行测试时,此框架将为每次运行创建报告。命令。我们需要自定义报告以包含更多细节,但每次运行maven命令时,它都会下载jmeter资源并更新框架中的目标文件夹。因此,我们将清除所有定制,并且无法创建预期报告。 我的POM如下所示
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blazemeter</groupId>
<artifactId>mvn-jmeter</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-jmeter-demo</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<generateReports>true</generateReports>
<jMeterProcessJVMSettings>
<xms>1024</xms>
<xmx>1024</xmx>
<arguments>
<argument>-Xprof</argument>
<argument>-Xfuture</argument>
</arguments>
</jMeterProcessJVMSettings>
<propertiesUser>
<testdatafile>${testdatafile}</testdatafile>
<suite>${suite}</suite>
</propertiesUser>
<testFilesIncluded>
<jMeterTestFile>testplans/${jmxfile}</jMeterTestFile>
</testFilesIncluded>
</configuration>
</plugin>
</plugins>
</build>
</project>
非常感谢任何解决问题的帮助。
答案 0 :(得分:1)
如果在 $ {project.base.directory} / src / test / jmeter 中找到以下属性文件,将使用以下属性文件:
- jmeter.properties
- saveservice.properties
- upgrade.properties
- system.properties
- user.properties
- global.properties
因此,您只需在 user.properties 文件中执行必需的配置覆盖,并将该文件放到JMeter .jmx脚本所在的文件夹中。 Maven插件会选择它并覆盖相关值
或者,您可以直接在 pom.xml 文件中覆盖任何属性,方法是在configuration/propertiesJMeter
部分指定它们。
下面的示例告诉JMeter将结果存储为xml
并保存响应数据:
<propertiesJMeter>
<jmeter.save.saveservice.output_format>xml</jmeter.save.saveservice.output_format>
<jmeter.save.saveservice.response_data>true</jmeter.save.saveservice.response_data>
</propertiesJMeter>
完整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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blazemeter</groupId>
<artifactId>mvn-jmeter</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>maven-jmeter-demo</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>verify</phase>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- save response data -->
<propertiesJMeter>
<jmeter.save.saveservice.output_format>xml</jmeter.save.saveservice.output_format>
<jmeter.save.saveservice.response_data>true</jmeter.save.saveservice.response_data>
</propertiesJMeter>
<generateReports>true</generateReports>
<jMeterProcessJVMSettings>
<xms>1024</xms>
<xmx>1024</xmx>
<arguments>
<argument>-Xprof</argument>
<argument>-Xfuture</argument>
</arguments>
</jMeterProcessJVMSettings>
<propertiesUser>
<testdatafile>${testdatafile}</testdatafile>
<suite>${suite}</suite>
</propertiesUser>
<testFilesIncluded>
<jMeterTestFile>testplans/${jmxfile}</jMeterTestFile>
</testFilesIncluded>
</configuration>
</plugin>
</plugins>
</build>
</project>
更多信息: