maven - 如何使用 jmeter maven 插件运行特定的 jmx 文件
问题描述
我正在使用 Jmeter Maven 插件(http://jmeter.lazerycode.com)来触发我的 maven 项目中的 jmx 文件。有没有办法可以指定在运行时运行哪个 jmx 文件,而不是 pom.xml 中的插件配置 testFilesDirectory、testFilesExcluded、testFilesIncluded 等。在 jmeter 命令行模式下,我们可以使用 -t 指定。
jmeter -n -t mytest.jmx
jmeter maven插件中是否有类似的选项
解决方案
这个<testFilesIncluded>
标签有什么问题?
如果您定义一个Maven 属性,例如
<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>
更多信息:
推荐阅读
- regex - 匹配前面不带星号的所有日期
- c# - 将 DBContext 与 Oracle 一起使用
- java - 如何在sql表中自动插入日期和时间
- javascript - 将图像添加到元素
- c# - Azure - 在不同区域出现错误
- slack - Slack App安装中的环境变量?
- javascript - 提交/加载/提交/编辑保存数据
- javascript - React Native 中的偏移 RefreshControl
- java - 如何使用 AndroidX 为 Activity 创建选项菜单?
- google-sheets - 我可以让谷歌表格评估一个字符串输入,就好像它是一个公式一样?