It might be useful to be able to exit a loop prematurely.
More than 'might be useful'(!) In load testing of complex web applications with multiple scenarios consisting of multiple steps, the inability to terminate a loop is a big issue. In order to end a loop based on a response (i.e. as part of the test design), a complex arrangement of controllers can sometimes be arranged (While, If etc). Terminating a iteration loop in the event of error is next to impossible. Failure of a single test step frequently leads to a cascade failure of remaing steps in the loop. The problem is that this skews the results. What is in fact 1 error gets reported as many problems. The ability to exit a loop (but maintain the thread) should be accessible programatically (beanshell?) and embedded within controllers (terminate loop on error)
Looks like this could be related to: #30563 (Although the fix attached to that issue appears to be doing something slightly different to the functionality described in the request)
Yes, Bug 30563 is slightly different in that it skips to the next iteration of the enclosing loop, rather than exitting the loop entirely. It would be useful to have both NEXT and LAST functionality. Maybe the NEXT patch can be extended. As to BeanShell access, that should be fairly trivial to arrange once the functionality has been added.
Unfortunately, the patch provided in bug 30563 does not work properly.
Start next loop option has now been fixed. *** This bug has been marked as a duplicate of bug 30563 ***
"Start next loop" - good, but it is not the same as "exit from loop" In some cases it is needed to exit loop. Now we can use "While" controller with condition, and inside this controller we can set some flag so at next time condition of "while" controller will become false and loop will interrupt. But it would be more clear and more comfortable to use "loop controller", and exit from loop by condition inside loop... Is it planned to do it?
I would like to see this reopened to cover starting the next thread loop without registering a sample error. Per comment 3 this is different from what's offered by bug 30563. In my test plan I have a login fragment that chooses a random user from all possible users in my test data. A few of these users are setup with no data, which is a valid scenario in production for brand new users. In this case they are given a no-data page in response to logging in as there is no functionality yet available for them. I then have thread groups for each of my test scenarios that include the login fragment. If I use an assertion to fail the login fragment when the no data page is returned, and the Start Next Thread option on the thread group from bug #30563, the issue is the Summary Report and View Results Tree listeners show the no data cases as errors, which they are not. The only other option I can think of is to capture the no-data state with a post-processor, and use an If controller in every single thread group that uses my login fragment to test for the no data scenario before proceeding. This is a lot of duplication in my test plan. If I could place that If controller in the fragment, and use a "Start Next Thread Loop" Test Action that might do the trick. If I could flag a given assertion to not register as a sample error, but still trigger the thread group's "Start Next Loop" functionality that might also do. Referring to comment 3 I can also see a use for a "Start Next Loop" Test Action that would apply to the closest loop controller, or the thread loop as applicable (basically the equivalent of the "continue" keyword in Java).
I have a fix for this one, will commit it once 2.6 vote is done.
Date: Thu Feb 2 12:50:53 2012 New Revision: 1239590 URL: http://svn.apache.org/viewvc?rev=1239590&view=rev Log: Bug 45839 - Test Action : Allow premature exit from a loop Modified: jmeter/trunk/src/components/org/apache/jmeter/sampler/TestAction.java jmeter/trunk/src/components/org/apache/jmeter/sampler/gui/TestActionGui.java jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContext.java jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java jmeter/trunk/xdocs/changes.xml
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2154