There is a Test plan in with set of related requests. If first request fails then I need skip subsequent request as they will anyways fail. How can I achieve this in JMeter.
Test Plan
ThreadGroup(Number of threads:2)
Request1
Request2
Request3
Request4
For example: If Request1 fails due to some error then thread should not execute Request2, Request3, Request4. as Request2,3 & 4 use token from request1 and it will anyways fail if request fails. Can it be achieved using Start Next Thread Loop and Stop Thread. what is the different between these two options
>Solution :
Each JMeter thread (virtual user) you define in the Thread Group executes Samplers upside down.
When there are no more Samplers to execute or loops to iterate – the thread is being shut down. When there are no more running threads – the test will fail.
- Start Next Thread Loop – ignore the error, start next loop and continue with the test, so if
Request1fails – JMeter will simply go to the next iteration of the Thread Group and will try to executeRequest 1one more time until it will be successful. The failure will be recorded in the .jtl results file - Stop Thread – current thread exits, it means that the current thread will be shut down and won’t execute anything. The failure will be recorded in the .jtl results file
Another option is use If Controller with ${JMeterThread.last_sample_ok} pre-defined variable as the condition, if you design your test plan like this:
the Request2 will only be executed only if Request1 is successful
