I need a way to stop my main sample from being executed and also stop my test.
I have read this post on stackoverflow but this does not prevent the main sample from being executed. JMeter - Stop Thread from within a BeanShell PreProcessor
I have an HTTP sampler (Could be any other samples besides a BeanShell sampler) in JMeter 3.2 with a BeanShell PreProcessor that contains the following line of code:
org.apache.jmeter.engine.StandardJMeterEngine.stopThread(Thread.currentThread().getName());
Now this does stop my test but not after executing the main sample. So I need something that stops my test and prevents the main sample from ever being executed.
Any help would be greatly appreciated!
Just call ctx.getEngine().askThreadsToStop()
where required, it will perform graceful shutdown.
More "hard" methods are:
ctx.getEngine().stopTest();
or even
System.exit(1);
Remember that using Beanshell for scripting is not recommended, starting from JMeter 3.1 users are encouraged to switch to JSR223 Test Elements and Groovy language, check out Apache Groovy - Why and How You Should Use It for details.