The first Simple Controller in Switch Controller is always the Default one, and the other ones below that are cases.
In this example, we have 3 Simple Controllers inside the Switch Controller. So, the first one is our Default Case, second one is Case 1 and third one is Case 2.
That means if we pass the value “1” to Switch Controller, Samplers inside our Case 1 are going to trigger and if we pass “2” same thing is going to happen for Case 2.
In this case, if we pass any variable except “1” and “2” it will trigger our Default case.
Let’s experience that on our example. We got the values “0,0,0,1,1,2,2,5,5,5” in our CSV. We expect Option 1 and Option 2 to work when we get “1” and “2”, but for any other values Default one should work.
Let’s set the iteration as 10, add JSR223 Sampler in each Simple Controller and take a console log to see how it is going to work.
Option 1 logged for “1”, Option 2 logged for “2“ and Default logged for “0” and “5”.
That’s it! Now you know how to use switch controller & simple controller on JMeter. To keep learning and staying up to date, keep in touch with Loadium blog posts. Happy load testing with Loadium!