如何避免 Maven 文件夹结构中的目标文件夹更新

How to avoid target folder update in maven folder structure

我们已经使用 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>

非常感谢任何解决问题的帮助。

根据Basic Configuration chapter

The following properties files will be used if they are found in ${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>

更多信息: