JMeter - 如何在 IF 控制器中使用多个条件? [英] JMeter - How can I use multiple conditions in IF Controller?

查看:49
本文介绍了JMeter - 如何在 IF 控制器中使用多个条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

在 If Controller -> 条件(默认 Javascript)中,我提供以下内容"${responsecode}" == "404" ||"${responsecode}" == "500" &&${responseMessage}" == 未找到"

解决方案

是的,您可以,假设您当前的条件 SMTP Sampler 将被执行:

  • 如果 ${responsecode} 变量是 404

    OR

  • 如果 ${responsecode} 变量是 500 AND ${responseMessage} 变量是 <代码>未找到

<小时>

我怀疑您是否会收到

参见 如何使用 JMeter 的 'IF' Controller 文章,了解有关通过 If Controller 有条件地运行采样器的更多详细信息.

Here is my code:

In If Controller -> Condition (Default Javascript) I am providing following "${responsecode}" == "404" || "${responsecode}" == "500" && "${responseMessage}" == "Not Found"

解决方案

Yes you can, assuming your current condition SMTP Sampler will be executed:

  • If ${responsecode} variable is 404

    OR

  • If ${responsecode} variable is 500 AND ${responseMessage} variable is Not Found


I doubt that you will get Not Found message given Response Code 500, most likely you will get an Internal Server Error there so maybe you should amend your condition to look like:

"${responsecode}" == "500" || ("${responsecode}" == "404" && "${responseMessage}" == "Not Found")

In case when If Controller doesn't behave as expected first of all check jmeter.log file for any JavaScript-related errors, it will give you some clue regarding what's wrong with your setup. You can also use __javaScript() function and View Results Tree listener combination to visualize the result of your If Controller condition:

See How to Use JMeter's 'IF' Controller article for more details on conditionally running samplers via If Controller.

这篇关于JMeter - 如何在 IF 控制器中使用多个条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆