一。禁用<testResultsTimestamp>
默认情况下,会为生成的每个结果文件增加一个时间戳,如果你不想添加时间戳,可通过配置<testResultsTimeStamp>为false来禁用此行为
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<testResultsTimestamp>false</testResultsTimestamp>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
二。启用<appendResultsTimestamp>
当<testResultsTimestamp>设置为true时,时间戳默认定位于文件名的开头,你可以将<appendResultsTimestamp>设置为true,时间戳会定位于文件名的结尾
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<appendResultsTimestamp>true</appendResultsTimestamp>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
三。设置<resultsFileNameDateFormat>
添加到文件名的时间戳默认格式为基本的ISO_8601日期格式(YYYMMDD),你可以通过修改配置<resultsFileNameDateFormat>来设定所需的时间戳格式,示例使用JodaTimeDateFormatter(参考http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html)
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<resultsFileNameDateFormat>MMMM, yyyy</resultsFileNameDateFormat>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
四。选择<resultsFileFormat>
JMeter能生成jtl测试结果(xml格式)和cvs测试结果。默认情况下,2.6.0版本之后生成csv格式。如果需要,可以将其切换成xml格式。请注意,插件JMeter Analysis Maven还不支持csv格式。
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<resultsFileFormat>csv</resultsFileFormat>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
五。指定<resultsDirectory>
默认的jmeter测试结果将会保存于${project.base.directory}/target/jmeter/results. 你可以通过<resultDirectory>标签来指定想要保存的位置。
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<resultsDirectory>/tmp/jmeter</resultsDirectory>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
六。设置<ignoreResultsFailures>
默认情况下,如果在jtl或csv文件中发现任何错误,maven将会停止运行。如果你不想maven中断,可以通过设置<ignoreResultsFailures>标签来忽略错误
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
<execution>
<id>jmeter-check-results</id>
<goals>
<goal>results</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreResultFailures>true</ignoreResultFailures>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
七。设置<suppressJMeterOutput>
默认情况下,jmeter将输出打印到控制台。如果不想查看jmeter生成的log,可以通过配置<suppressJMeterOutput>为true将其关闭
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<suppressJMeterOutput>true</suppressJMeterOutput>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
八。设置<skipTests>
你可以使用<skipTests>标签使maven跳过性能测试,配置如下:
+---+
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>USE LAST VERSION</version>
<executions>
<execution>
<id>jmeter-tests</id>
<goals>
<goal>jmeter</goal>
</goals>
</execution>
</executions>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
+---+
运行
mvn verify –DskipTests=true
性能测试将会被跳过