0
votes

My test plan is below !TestPlan ThreadGroup LoopController1 Sampler1 BeanShellPostProcessor Listener LoopController2 Sampler2

As part of Beanshellpostprocessor, i am putting count value to a variable props.put("noOfRecords",vars.get("msg_#"));

Now this value i am placing on 2nd loopcontroller as ${__P(noOfRecords,0)}

This setup is failing for iterations where we don't have any records. So the previous "${__P(noOfRecords,0)}" value is considered while running the Loop2.

Is there any other way we can achieve the dynamic loop counter?

1

1 Answers

0
votes

You can use variables or properties in the Loop Controller to change the loop count at run time.

If the Property/Variable is set correctly by the Beanshell postprocessor in your test, It should work. That is, you need to set the value to 0 explicitly when there is no record. Otherwise Properties (which are not destroyed until you close JMeter) might use the previous value.