I have a JMeter test plan with following http request samplers.
When I execute the test plan with 5 parallel threads, I see that the sampler 2 is called before calling sampler 1 for some threads, which then fails the response assertions.
Is there any way to specify a sequence of samplers to be executed ?
To remember the execution order, use the acronym CONF-PTS-PAL. When you click on Run button for the above test plan, first JMeter will look for any configuration elements are present or not. If it finds, those will be executed first. Then it looks for any Pre Processors and then Timers.
This should ensure that they are executed sequentially :
So let's start with thread group.
Number of Threads(users) is 5.
So assuming you have the logic work out for your login sampler. Just add additional sampler to it. So right click on that sample Add > Post Processors > BSF PostProcessor
, inside this post processor big script space write ${__setProperty(ThreadValue,${__threadNum},)}
.
This will save the thread number to your property called ThreadValue
. Make sure you select your language as beanshell
in the dropdown list.
Then after the login sampler add the if controller. Add this to the condition field (${JMeterThread.last_sample_ok}==true) && (${__property(ThreadValue,,)} == ${__threadNum})
What this means is that -> do only logged in stuff while the actual login is successful and if the login thread matches the thread you're currently in.
That's it you do your login stuff only inside the if controller. If you want to be sure that you logout the right user place additional if controller arround it.
Cheers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With