Description
- By using a switch controller, one can move any child element under that Switch controller with switch value.
- Switch value can be an integer value or a string value.
- Elements under the switch controller are numbered from switch value 0.
- The only element with switch value is executed under the switch controller, rest all other elements are skipped for the execution.
Parameters
Attribute
|
Description
|
Name
|
Descriptive name of the switch controller to show in Test Plan.
|
Switch Value
|
Integer or string value.
- If switch value is out of range or empty it will run zeroth element.
- If Switch Value is a String value then it searches for element with same string value. These are case-sensitive.
- If string value is not match then element with name ‘default’ is executed (default is Case-Insensitive).
- If default is not present, then controller will not run anything.
|
Use Case 1
Using integer value in switch controller.
Test Plan Structure -
The test plan contains 1
simple thread group, 1 counter element, 1 switch controller. Inside the switch
controller, there is one Transaction Controller with two Dummy Samplers, and 3
Dummy samplers.
Setting in the Thread
Group:
1 thread with 4 iterations-
Counter element has a variable called SWITCH_VALUE and its
value starts from 0 and incremented by 1 in each iteration. There are total 4
iterations in the thread group. So, value of SWITCH_VALUE is 0 in 1st
iteration, 1 in 2nd iteration, 2 in 3rd iteration and 3
in 4th iteration.
The value of
SWITCH_VALUE is provided in the Switch controller.
Setting in Switch Controller:
Output:
Explanation:
- In First iteration, value of SWITCH_VALUE is 0, so Transaction Controller is executed in first iteration. Therefore Dummy Sampler 1 and Dummy Sampler 2 will be executed.
- In Second Iteration, value of SWITCH_VALUE is becomes 1, so Dummy Sampler 3 will be executed.
- In third Iteration, value of SWITCH_VALUE is becomes 2, so Dummy Sampler 4 will be executed.
- In fourth Iteration, value of SWITCH_VALUE is becomes 3, so Dummy Sampler 5 will be executed.






