【问题标题】:How to set the Jmeter properties in xml file如何在 xml 文件中设置 Jmeter 属性
【发布时间】:2018-04-19 13:15:56
【问题描述】:

我在我的 POM.XML 中使用下面的 JMeter maven 插件

<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.7.0</version>

如果我想使用 maven 命令执行 JMX 文件,我使用以下标签更新了我的 pom.xml 文件

在我的构建块之外

<properties>
<my.host>localhost</my.host>
</properties>

在配置块中

<configuration>                       
<propertiesUser> 
<hostName>${my.host}</hostName> 
</propertiesUser> 
</configuration> 

我使用以下命令运行使用 MVN 运行 JMeter

mvn verify  -Dmy.host=www.test.com

但是当我执行上述命令时,我无法在命令窗口中看到更改,所以我想在我的 JMX 文件中添加任何内容来运行此命令。

【问题讨论】:

    标签: maven jmeter jmeter-maven-plugin


    【解决方案1】:

    您的配置看起来不错,您应该可以在需要时通过__P()__property() 函数引用属性值。

    如果您想将属性值打印到运行 Maven 的控制台 - 您可以使用 __groovy() function。相关代码将类似于:

    ${__groovy(println('Current hostName value:'+ props.get('hostName')),)}
    

    输出将是:

    请参阅Apache JMeter Functions - An Introduction 以了解有关 JMeter 函数概念的更多信息。

    【讨论】:

      猜你喜欢
      • 2018-03-02
      • 2017-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 2018-08-30
      相关资源
      最近更新 更多