Jmeter - 根据Response断言结果执行代码

时间:2017-08-31 10:14:49

标签: jmeter conditional-statements assertion

尝试在脚本中放置一些条件逻辑,以便仅基于成功验证响应断言来执行某些步骤。

我的剧本: 主执行线程

- 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提取器作为最后一步令人不安的事实。

2 个答案:

答案 0 :(得分:1)

你犯了一个错误。代码是“区分大小写”。

以下是If Controller的配置方式:

enter image description here

答案 1 :(得分:0)

条件应该与If Controller中的 $ {JMeterThread.last_sample_ok} == true 一样。

相关问题