基于线程组一中的条件的多线程组执行
Multiple thread group execution based on a condition in thread group one
我有多个线程组(2 个线程组),根据条件,一个线程组应该 运行,如果条件失败,则不应 运行 线程组 2.
- 线程组一
- 正则表达式 - 成功
- BeanShell 断言 -
${__setProperty(success,${success})};
线程组二如果控制器 -
${__jexl3("${success}"== "Save and submit was successful")}
预期 - 基于线程组 2 执行流程的条件应该 运行。
您需要检查 props
中的值并使用 __groovy
和 equals
比较字符串:
${__groovy("Save and submit was successful".equals(props.get("success")))}
您的 ${success}
表达式代表 JMeter 变量,而您需要评估 JMeter 属性。
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.
因此您需要修改 If Controller 的条件以包含 __P() function 如:
${__jexl3("${__P(success,)}"=="Save and submit was successful",)}
请注意,您必须在 Test Plan level. In the majority of case it's better to go for Inter-Thread Communication Plugin, check out SynchronizationExample.jmx 演示测试计划上勾选 Run Thread Groups consecutively
方框
我有多个线程组(2 个线程组),根据条件,一个线程组应该 运行,如果条件失败,则不应 运行 线程组 2.
- 线程组一
- 正则表达式 - 成功
- BeanShell 断言 -
${__setProperty(success,${success})};
线程组二如果控制器 -
${__jexl3("${success}"== "Save and submit was successful")}
预期 - 基于线程组 2 执行流程的条件应该 运行。
您需要检查 props
中的值并使用 __groovy
和 equals
比较字符串:
${__groovy("Save and submit was successful".equals(props.get("success")))}
您的 ${success}
表达式代表 JMeter 变量,而您需要评估 JMeter 属性。
Properties are not the same as variables. Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function.
因此您需要修改 If Controller 的条件以包含 __P() function 如:
${__jexl3("${__P(success,)}"=="Save and submit was successful",)}
请注意,您必须在 Test Plan level. In the majority of case it's better to go for Inter-Thread Communication Plugin, check out SynchronizationExample.jmx 演示测试计划上勾选 Run Thread Groups consecutively
方框