【问题标题】:Jmeter - Execute code based on Response assertion resultJmeter - 根据响应断言结果执行代码
【发布时间】:2017-08-31 10:14:48
【问题描述】:

尝试将一些条件逻辑放入脚本中,以便仅根据响应断言的成功验证执行某些步骤。

我的脚本: 主执行线程

- Submit Http request
-- Response assertion code 200 (indicates request successfully submitted)
-- Response assertion contains string (I expect a specific string back if successful)
-- Json extractor (extract the string I tested for in the response for later use)
- Do a bunch of other stuff

我的问题是,如果我得到预期的字符串,我只想执行“一堆其他东西”(没有它,一切都会失败)。

我需要一个条件测试,只有在第二个响应断言通过时才执行。

我尝试过使用"${JmeterThread.last_sample_ok}",但这给了我If controller: error while processing ... BAD CONDITION...expected true or false的错误

我假设我把“if”放在了错误的位置,或者只是不恰当地使用了条件。

有什么建议吗?

更新:

我的脚本目前如下所示:

- If test record is version 0
-- Send http to version 0 api
--- Response code assertion 200
--- Response assertion message contains specific string
--- Json extractor to extract the data associated with the string
-- If "${JmeterThread.last_sample_ok}"
--- Do other stuff

我假设我将包含“最后一个样本正常”的 If 放置在错误的级别,或者事实上有一个 json 提取器作为上一步的最后一步,这让事情变得不安。

【问题讨论】:

  • 你能展示你的 if 控制器吗?
  • 更新了主要描述
  • 请显示组件If Controller的屏幕截图,而不是伪代码。谢谢
  • 抱歉 UBIK,无法显示截图。独立的系统和雇主对专有的东西非常敏感(而且我不喜欢找工作!):)
  • 我用狐狸更新了我的答案。如果可以,请接受它,以便帮助他人

标签: jmeter conditional-statements assertion


【解决方案1】:

以防万一,你犯了一个错误。代码“区分大小写”。

If Controller 的配置方式如下:

【讨论】:

  • 谢谢。我复制的例子有错误。感觉我需要一个手掌表情符号!
【解决方案2】:

条件应该类似于 If Controller 中的 ${JMeterThread.last_sample_ok}==true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多