【问题标题】:How to run a gatling test from a java code and pass the url of test in parameters of simulation?如何从 java 代码运行加特林测试并在模拟参数中传递测试的 url?
【发布时间】:2021-04-19 15:53:36
【问题描述】:

我希望能够从 java 代码,特别是测试的 url 将参数传递给 Gatling Simulation。我将 Gatling 与 maven 方法一起使用。请有人帮帮我。

【问题讨论】:

    标签: java spring-boot maven gatling scala-gatling


    【解决方案1】:

    一种方法是: 比如我需要通过测试下的URLhttp://127.0.0.1:5000

     mvn clean gatling:test -Dfoo="http://127.0.0.1:5000"
    

    在 Scala 代码中选择这个变量:

    val foo_url = System.getProperty("foo")
    

    并在模拟中使用此 foo_url:

    val httpProtocol = http
        //.baseUrl("http://127.0.0.1:5000")
        .baseUrl(foo_url)
    

    【讨论】:

    • 我可以知道您收到的错误吗?如果可能的话,还有一个关于你的代码外观的代码 sn-p。
    • 谢谢它现在工作我的错误是使 URL 介于 ' ' 而不是 " "
    猜你喜欢
    • 2022-11-23
    • 2012-10-26
    • 1970-01-01
    • 2016-06-16
    • 2018-03-14
    • 2022-06-13
    • 1970-01-01
    • 2015-09-13
    • 1970-01-01
    相关资源
    最近更新 更多