【问题标题】:Unable to pass arguments to a .jmx files from build.gradle file through jmRun无法通过 jmRun 将参数从 build.gradle 文件传递​​给 .jmx 文件
【发布时间】:2019-02-12 13:22:52
【问题描述】:

我的 .jmx 文件面临多个问题。

我正在使用 bzm 并发线程组

1) 无法识别传递用户定义值的标准格式 比如:${__P(SERVER_NAME,localhost)} 而不是将“localhost”传递给我的脚本,而是将“${__P(SERVER_NAME,localhost)}”附加到我的 url。

仅传递值后,即(本地主机)它工作正常

2) 另外,我正在从 build.gradle 文件运行我的 jmeter 脚本,但我无法从它们传递 url 和其他详细信息

|SERVER_NAME|${__P(SERVER_NAME,localhost)}| --> 这段代码不工作 |SERVER_NAME|本地主机| --> 这段代码运行良好

jmeter {
jmTestFiles = [file("src/main/Jmetrscript.jmx")]
jmSystemPropertiesFiles= [file(path of my properties file)] //to add additional system properties

jmUserProperties = ["SERVER_NAME ="+System.getProperty('SERVER_NAME','localhost'), "SERVER_PORT ="+System.getProperty('SERVER_PORT','9080') ]

enableExtendedReports = true //produce Graphical and CSV reports

}

当我使用 gradlew jmRun -DSERVER_NAME=localhost 运行它时,它没有传递值。

【问题讨论】:

    标签: gradle jmeter build.gradle gradlew


    【解决方案1】:

    根据JMeter Gradle Plugin - Advanced Usage

    支持的 JMeter 命令行参数 (see full list here):

    -p, --propfile {argument}, the jmeter property file to use
    -q, --addprop {argument}, additional property file(s)
    -t, --testfile {argument}, the jmeter test(.jmx) file to run
    -J, --jmeterproperty {argument}={value}, Define additional JMeter properties
    -D, --systemproperty {argument}={value}, Define additional System properties
    -S, --systemPropertyFile {filename}, a property file to be added as System properties
    -r, --runremote (non-GUI only), Start remote servers (as defined by the jmeter property remote_hosts)
    -G, --globalproperty (argument)[=(value)], Define Global properties (sent to servers), e.g. -Gport=123,  or -Gglobal.properties
    

    所以你应该通过 -J 命令行参数传递 JMeter 属性,例如:

    jmRun -JSERVER_NAME=localhost etc
    

    参考资料:

    【讨论】:

    • 它不工作。显示以下错误 Unknown command-line option '-J'。
    • 你的 gradle 插件版本是什么?
    • iam 使用 gradle.plugin.net.foragerr.jmeter:jmeter-gradle-plugin:1.1.0-4.0 而我的 gradle 版本是 distributionUrl=https\://services.gradle.org/distributions /gradle-3.5-all.zip
    猜你喜欢
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 2012-12-08
    相关资源
    最近更新 更多