Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to run an JMeter test plan that it should be completed in specified time or it should be terminated within that stipulated time? Please throw me light on this question.

share|improve this question
up vote 3 down vote accepted

It isn't possible at Test Plan level, but there are following options available:

  1. Set Duration (seconds) to the desired value for each Thread Group
  2. Use Test Action timer to stop all the threads (for example create a separate thread group, add Constant Timer which will sleep desired number of seconds, when the timer all threads will be requested to stop
  3. Use Beanshell Sampler anywhere in your script. Relevant Beanshell code to stop the test looks as follows:

    SampleResult.setStopTest(true); // to ASK threads to stop
    SampleResult.setStopTestNow(true); // to TELL threads to stop

Using Duration or Stop doesn't mean that your test plan will end at that moment as threads need some time to gracefully shut down.

In case of forceful termination threads may produce extra errors which will be reflected in test results.

Hope this helps.

share|improve this answer
can i use beanshell timer? – Emmanuel Angelo.R Apr 28 '14 at 12:33

You can do this by using JMeter Scheduler: In Thread Group tick the Scheduler and set the value as below:

Start Time and End Time: No need to input. keep them as they are, because they have no significant after entering Duration and Startup delay value. Delay overrides Start Time, and Duration overrides End Time.

For example, if you want to run the test for 2 min. Input the value as below:

Duration (seconds): 120
Startup delay (seconds): 0

enter image description here

Now it's the time to run the test: Run -> Start

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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