Jmeter 提取和在 If Controller 上使用
Jmeter extraction and using on If Controller
有没有什么方法可以模拟这种情况,示例如果提取了一个值,它将执行“TC1”请求,但如果我提取了空白值,它将执行“TC2”。
提供最大灵活性的最简单方法是使用 Switch Controller
根据文档:
If the switch value is out of range, it will run the zeroth element, which therefore acts as the default for the numeric case. It also runs the zeroth element if the value is the empty string.
If the value is non-numeric (and non-empty), then the Switch Controller looks for the element with the same name (case is significant). If none of the names match, then the element named "default" (case not significant) is selected. If there is no default, then no element is selected, and the controller will not run anything.
所以给定以下 Test Plan 结构:
- 开关控制器,开关值 - 您提取的变量
- Simple Controller 任意名称
- TC2 采样器作为开关控制器的子(ren)
- 名称为
default
的简单控制器
- TC1 采样器作为开关控制器的 chidr(ren)
演示:
更多信息:Running JMeter Samplers with Defined Percentage Probability
有没有什么方法可以模拟这种情况,示例如果提取了一个值,它将执行“TC1”请求,但如果我提取了空白值,它将执行“TC2”。
提供最大灵活性的最简单方法是使用 Switch Controller
根据文档:
If the switch value is out of range, it will run the zeroth element, which therefore acts as the default for the numeric case. It also runs the zeroth element if the value is the empty string.
If the value is non-numeric (and non-empty), then the Switch Controller looks for the element with the same name (case is significant). If none of the names match, then the element named "default" (case not significant) is selected. If there is no default, then no element is selected, and the controller will not run anything.
所以给定以下 Test Plan 结构:
- 开关控制器,开关值 - 您提取的变量
- Simple Controller 任意名称
- TC2 采样器作为开关控制器的子(ren)
- 名称为
default
的简单控制器- TC1 采样器作为开关控制器的 chidr(ren)
- Simple Controller 任意名称
演示:
更多信息:Running JMeter Samplers with Defined Percentage Probability