Jmeter - 根据响应断言结果执行代码
Jmeter - Execute code based on Response assertion result
尝试在脚本中放置一些条件逻辑,以便仅在成功验证响应断言的基础上执行某些步骤。
我的脚本:
主执行线程
- 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
我的问题是,如果我返回预期的字符串(没有它,一切都会失败),我只想执行 '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
我假设我将包含 'last sample ok' 的 If 放在了错误的级别,或者事实上有一个 json 提取器作为最后一个步骤,这让事情变得混乱。
为了以防万一,你犯了一个错误。代码是“区分大小写”。
If Controller 的配置方式如下:
条件应该类似于 If 控制器中的 ${JMeterThread.last_sample_ok}==true。
尝试在脚本中放置一些条件逻辑,以便仅在成功验证响应断言的基础上执行某些步骤。
我的脚本: 主执行线程
- 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
我的问题是,如果我返回预期的字符串(没有它,一切都会失败),我只想执行 '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
我假设我将包含 'last sample ok' 的 If 放在了错误的级别,或者事实上有一个 json 提取器作为最后一个步骤,这让事情变得混乱。
为了以防万一,你犯了一个错误。代码是“区分大小写”。
If Controller 的配置方式如下:
条件应该类似于 If 控制器中的 ${JMeterThread.last_sample_ok}==true。