【问题标题】:how to run a specific jmx file using jmeter maven plugin如何使用 jmeter maven 插件运行特定的 jmx 文件
【发布时间】:2019-02-11 19:52:10
【问题描述】:
我正在使用 Jmeter Maven 插件 (http://jmeter.lazerycode.com) 来触发我的 maven 项目中的 jmx 文件。
有没有办法可以指定在运行时运行哪个 jmx 文件,而不是 pom.xml 中的插件配置 testFilesDirectory、testFilesExcluded、testFilesIncluded 等。
在 jmeter 命令行模式下,我们可以使用 -t 指定。
jmeter -n -t mytest.jmx
jmeter maven插件中是否有类似的选项
【问题讨论】:
标签:
maven
jmeter
jmeter-maven-plugin
【解决方案1】:
这个<testFilesIncluded> 标签有什么问题?
如果你定义一个Maven Property 像
<properties>
<jmeterScript>test1.jmx</jmeterScript>
</properties>
并在 JMeter Maven 插件中将其称为:
<configuration>
<testFilesIncluded>
<jMeterTestFile>${jmeterScript}</jMeterTestFile>
</testFilesIncluded>
</configuration>
您将能够使用-D 命令行参数覆盖属性值,例如:
mvn -DjmeterScript=someTest.jmx clean verify
或
mvn -DjmeterScript=someOtherTest clean verify
完整的 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>com.example</groupId>
<artifactId>jmeter</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<jmeterScript>test1.jmx</jmeterScript>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.8.5</version>
<executions>
<!-- 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>
<testFilesIncluded>
<jMeterTestFile>${jmeterScript}</jMeterTestFile>
</testFilesIncluded>
</configuration>
</plugin>
</plugins>
</build>
</project>
更多信息: