【问题标题】:why doesn't my doIf code block execute even if explicitly set the condition to true?为什么即使将条件显式设置为 true,我的 doIf 代码块也不执行?
【发布时间】:2020-10-22 19:40:00
【问题描述】:

这是使用 Gating Scala DSL 编写的 Gating 性能测试代码。

如果标志的值 ma​​keATP1value 这是一个 boolean 值设置为,我需要 randomSwitch 运行 50% 的时间真的。我不明白的是 - 为什么 doIf 条件不会评估为“true”并程序运行 randomSwitch 代码块。有人可以在这里查看并纠正我可能做错的地方吗?

下面是代码sn-p:

def submitConfirmOrderAnonymous = group("ATP1 Calls") {

    val makeATP1value : Boolean  = true

    doIf(makeATP1value){
      randomSwitch(50.0 -> exec(PurchaseFalabella.makeAtp1CallBeforeSubmitConfirmOrder))
    }

exec(Purchase.submitConfirmOrderAnonymous)

}

【问题讨论】:

    标签: conditional-statements performance-testing gatling scala-gatling


    【解决方案1】:

    你缺少一个.(点)来链接doIfexec,所以只有块的最后一条指令(exec)被传递给group,其余的( doIf) 被删除。

    【讨论】:

    • 如果我添加一个 . (点)将其链接到组,然后显示编译器错误; ' } ' 预计我在这里有点迷失了链接请求的正确方法``` object PaymentChainBuilder { def submitConfirmOrderLogin = group("ATP2 Calls"){ .doIf(makeATP1){ randomSwitch( 100.0 -> exec(PurchaseFalabella) .makeAtp1CallBeforeSubmitConfirmOrder)) // 新 API makeATP1 调用 // FalabellaConfig.makeATP1Percentage -> exec(PurchaseFalabella.makeAtp1CallBeforeSubmitConfirmOrder)) } exec(Purchase.submitConfirmOrderLogin) } ```
    • 点要放在exec之前,与前面的doIf相连。
    猜你喜欢
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    • 2017-05-05
    • 1970-01-01
    • 2015-12-26
    • 2020-12-24
    • 1970-01-01
    • 2018-06-25
    相关资源
    最近更新 更多