Skip to content

Commit 02bf414

Browse files
committed
Create and expose exceptions for libraries to use.
- Failure - ContinuableFailure - Error - FatalError - SkipExecution Fixes robotframework#3685.
1 parent 685f78e commit 02bf414

File tree

18 files changed

+244
-38
lines changed

18 files changed

+244
-38
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
Running suite 'Fatal Exception' with 6 tests.
1+
Running suite 'Fatal Exception' with 8 tests.
22
==============================================================================
3-
Fxxxxx
3+
Fxxxxxxx
44
------------------------------------------------------------------------------
55
FAIL: Fatal Exception.Python Library Kw.Exit From Python Keyword
6-
FatalCatastrophyException
6+
FatalCatastrophyException: BANG!
77
==============================================================================
8-
Run suite 'Fatal Exception' with 6 tests in *.
8+
Run suite 'Fatal Exception' with 8 tests in *.
99

1010
FAILED
11-
6 tests, 0 passed, 6 failed
11+
8 tests, 0 passed, 8 failed
1212

1313
Output: *.xml

atest/robot/running/continue_on_failure.robot

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ Continue in for loop
9696
Continuable and regular failure in for loop
9797
Check Test Case ${TESTNAME}
9898

99+
robot.api.ContinuableFailure
100+
Check Test Case ${TESTNAME}
101+
99102
*** Keywords ***
100103
Verify all failures in user keyword [Arguments] ${kw} ${where}
101104
Check Log Message ${kw.kws[0].msgs[0]} ContinuableApocalypseException: 1 FAIL

atest/robot/running/fatal_exception.robot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Exit From Java Keyword
1414
Check Test Case ${TESTNAME}
1515
Check Test Case Test That Should Not Be Run 3
1616

17+
robot.api.FatalError
18+
Run Tests ${EMPTY} running/fatal_exception/standard_error.robot
19+
Check Test Case ${TESTNAME}
20+
Check Test Case Test That Should Not Be Run
21+
1722
Multiple Suite Aware Exiting
1823
Run Tests ${EMPTY} running/fatal_exception/
1924
Check Test Case Exit From Python Keyword

atest/robot/running/test_case_status.robot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ Test Teardown is Run When Setup Fails
5050

5151
Test Setup And Teardown Fails
5252
Check Test Case ${TEST NAME}
53+
54+
robot.api.Failure
55+
Check Test Case ${TEST NAME}
56+
57+
robot.api.Error
58+
Check Test Case ${TEST NAME}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from robot.api import Failure, Error
2+
3+
4+
def failure(msg='I failed my duties'):
5+
raise Failure(msg)
6+
7+
8+
def error(msg='I errored my duties'):
9+
raise Error(msg)

atest/testdata/running/continue_on_failure.robot

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ Continuable and regular failure in for loop
174174
END
175175
Fail Should not be executed
176176

177+
robot.api.ContinuableFailure
178+
[Documentation] FAIL ${HEADER}\n\n
179+
... 1) 1\n\n
180+
... 2) 2\n\n
181+
... 3) 3\n\n
182+
... ${TEARDOWN ERROR}
183+
Raise Continuable Failure 1 standard=True
184+
Raise Continuable Failure 2 standard=True
185+
Fail 3
186+
Raise Continuable Failure Should not be executed
177187

178188
*** Keywords ***
179189
Continuable Failure In User Keyword In ${where}

atest/testdata/running/fatal_exception/01__python_library_kw.robot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Suite Teardown Log Suite Teardown
44

55
*** Test Cases ***
66
Exit From Python Keyword
7-
[Documentation] FAIL FatalCatastrophyException
7+
[Documentation] FAIL FatalCatastrophyException: BANG!
88
[Teardown] Log This should be executed
99
[Tags] some tag
1010
Exit On Failure
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*** Settings ***
2+
Library Exceptions
3+
4+
*** Test Cases ***
5+
robot.api.FatalError
6+
[Documentation] FAIL FatalError: BANG!
7+
Exit on failure standard=True
8+
Fail Should not be executed
9+
10+
Test That Should Not Be Run
11+
[Documentation] FAIL Test execution stopped due to a fatal error.
12+
Fail Should not be executed

atest/testdata/running/skip/skiplib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from robot.errors import SkipExecution
1+
from robot.api import SkipExecution
22

33

44
class CustomSkipException(Exception):

atest/testdata/running/test_case_status.robot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
*** Settings ***
2+
Library StandardExceptions.py
3+
14
*** Test Case ***
25
Test Passes
36
[Documentation] PASS
@@ -76,6 +79,14 @@ Test Setup And Teardown Fails
7679
Fail This should not be run
7780
[Teardown] Fail Teardown failure
7881

82+
robot.api.Failure
83+
[Documentation] FAIL I failed my duties
84+
Failure
85+
86+
robot.api.Error
87+
[Documentation] FAIL I errored my duties
88+
Error
89+
7990
*** Keyword ***
8091
Do Nothing
8192
No operation

0 commit comments

Comments
 (0)