Revision: 3903
Author: jussi.ao.malinen
Date: Wed Aug 25 05:10:22 2010
Log: documentation for exit for loop and tests for user library exiting for loop.
http://code.google.com/p/robotframework/source/detail?r=3903

Added:
 /trunk/atest/testresources/testlibs/ExitForLoopException.java
Modified:
 /trunk/atest/robot/core/exit_for_loop.txt
 /trunk/atest/testdata/core/exit_for_loop.txt
 /trunk/atest/testresources/testlibs/JavaExceptions.java
 /trunk/doc/userguide/src/CreatingTestData/AdvancedFeatures.txt

=======================================
--- /dev/null
+++ /trunk/atest/testresources/testlibs/ExitForLoopException.java Wed Aug 25 05:10:22 2010
@@ -0,0 +1,3 @@
+public class ExitForLoopException extends RuntimeException {
+       public static final boolean ROBOT_EXIT_FOR_LOOP = true;
+}
=======================================
--- /trunk/atest/robot/core/exit_for_loop.txt   Wed Aug 25 03:05:46 2010
+++ /trunk/atest/robot/core/exit_for_loop.txt   Wed Aug 25 05:10:22 2010
@@ -1,6 +1,6 @@
 *** Settings ***
 Suite Setup     Run Tests  ${EMPTY}  core/exit_for_loop.txt
-Force Tags      regression  pybot  jybot
+Default Tags      regression  pybot  jybot
 Resource        atest_resource.txt

 *** Test Cases ***
@@ -33,6 +33,10 @@
     ${tc} =  Check Test Case  Simple Exit For Loop
     Should Be Equal  ${tc.kws[0].kws[0].kws[0].name}  BuiltIn.Exit For Loop
     Should Be Empty  ${tc.kws[0].kws[0].kws[0].msgs}
+
+Exit For Loop With Userlibrary
+    [tags]  regression  jybot
+    Test And All Keywords Should Have Passed

 *** Keyword ***
 Test And All Keywords Should Have Passed
=======================================
--- /trunk/atest/testdata/core/exit_for_loop.txt        Wed Aug 25 03:05:46 2010
+++ /trunk/atest/testdata/core/exit_for_loop.txt        Wed Aug 25 05:10:22 2010
@@ -1,3 +1,6 @@
+*** Settings ***
+Library  JavaExceptions
+
 *** Test Cases ***
 Simple Exit For Loop
     :FOR  ${var}  IN  one  two
@@ -44,6 +47,12 @@
    [Documentation]  FAIL Exit for loop without enclosing for loop.
    With Only Exit For Loop

+Exit For Loop With Userlibrary
+    :FOR  ${var}  IN  one  two
+    \  Throw Exit For Loop
+    \  Fail  Should not be executed
+    Should BE Equal  ${var}  one
+

 *** Keyword ***
 With Loop
=======================================
--- /trunk/atest/testresources/testlibs/JavaExceptions.java Wed Apr 21 23:00:09 2010 +++ /trunk/atest/testresources/testlibs/JavaExceptions.java Wed Aug 25 05:10:22 2010
@@ -44,5 +44,9 @@
     public void throwExitOnFailure() {
         throw new FatalCatastrophyException();
     }
+
+    public void throwExitForLoop() {
+        throw new ExitForLoopException();
+    }

 }
=======================================
--- /trunk/doc/userguide/src/CreatingTestData/AdvancedFeatures.txt Tue Aug 24 11:37:09 2010 +++ /trunk/doc/userguide/src/CreatingTestData/AdvancedFeatures.txt Wed Aug 25 05:10:22 2010
@@ -375,6 +375,24 @@
================ =============== ========== ========== ======= ======= =======


+Exiting for loop
+''''''''''''''''
+
+Normally for loop is executed until all the elements of the loop have been
+looped through or an error occurs and the test case or keyword fails. However +sometimes execution of a for loop needs to be stopped before all elements of +the loop have been gone through. `BuiltIn keyword`_ :name:`Exit For Loop` can be
+used to exit the enclosing for loop.
+
+:name:`Exit For Loop` keyword can be used directly in a for loop or in a keyword +that the for loop uses. In both cases the test execution continues after the
+for loop. If executed outside of a for loop, the test fails.
+
+Exiting a for loop can also be initiated from a user library by raising an
+exception with :code:`ROBOT_EXIT_FOR_LOOP` attribute. Please see
+'Stopping test execution'_ for examples how to do this in Python and Java
+libraries.
+
 Repeating single keyword
 ''''''''''''''''''''''''

Reply via email to