We have an option in ThreadGroup to stop or continue threads in case of errors. But this option applies to all the samplers within ThreadGroup.

Is there any way by which we can apply this condition only to specific samplers. For example, I have Login samplers in my test Plan and I want to stop those threads only which fail for login samplers.

Any possible workaround for that in JMeter!

3 Answers 3


Add Beanshell PostProcessor as a child of the request which must be successful and put the following code into "Script" area:

if (!prev.isSuccessful()) {

where prev stands for associated parent SampleResult

See How to Use BeanShell: JMeter's Favorite Built-in Component guide for more information on using Beanshell in your JMeter tests

  • I had used an alternative approach that involved JMeter "Test Action". But your solution is much simpler and works great. thanks. Commented Feb 8, 2016 at 13:17
  • 1
    Am I guessing right that @Dmitri T is the main developer of Jmeter tool? :-) Commented Nov 10, 2017 at 15:33

If you need to limit this behavior to one request, add a Result Status Action Handler as a child of the request

enter image description here

It's in post processor, then if it fails you can configure what happens, e.g. Stop the Thread from carrying on.

enter image description here

  • Could you provide an example of this in use?
    – Swagin9
    Commented Nov 9, 2017 at 20:26
  • I have updated my answer to include a screenshot Commented Nov 10, 2017 at 15:14

To ignore an expected 401 error on a specific request use this in an JSR223 PostProcessor:

if (prev.getResponseCode() == '401') {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.