2
votes

I am creating a JMeter test plan in which I need to execute several times the same request. For each request execution, I have a beanshell script that does some specific logic and increments a counter in a specific situation. The problem is that when I add a beanshell assert to check if the value is according I expect, this assertion does not wait for the loop to finish, and executes before.

Any idea on how can I make JMeter executes an assertion only after the loop has finished?

1
Welcome to Stack Overflow. Please see How to create a Minimal, Complete, and Verifiable examplecoderpc

1 Answers

1
votes

JMeter assertions obey JMeter scoping rules, they are applied to the sampler(s) which are in their scope.

enter image description here

So if you want the assertion to be executed after the loop finishes - you need to add another sampler which will be doing nothing, i.e. Dummy Sampler and add your final assertion as a child of this sampler.

enter image description here

Also be aware that starting from JMeter 3.1 it is recommended to use JSR223 Elements and Groovy language for scripting so make sure to migrate from Beanshell on next available opportunity