Revision: 3209
Author: pekka.klarck
Date: Thu May 6 02:04:00 2010
Log: Implemented Fatal Error keyword
http://code.google.com/p/robotframework/source/detail?r=3209
Added:
/trunk/atest/robot/standard_libraries/builtin/fatal_error.txt
/trunk/atest/testdata/standard_libraries/builtin/fatal_error.txt
Modified:
/trunk/src/robot/libraries/BuiltIn.py
=======================================
--- /dev/null
+++ /trunk/atest/robot/standard_libraries/builtin/fatal_error.txt Thu May
6 02:04:00 2010
@@ -0,0 +1,16 @@
+*** Settings ***
+Force Tags regression pybot jybot
+Resource atest_resource.txt
+Suite Setup Run Tests ${EMPTY}
standard_libraries/builtin/fatal_error.txt
+
+***Test Cases***
+
+Test is stopped when `Fatal Error` keyword is used
+ Check Test Case ${TESTNAME}
+
+Subsequent tests are not executed after `Fatal Error` keyword has been used
+ Check Test Case ${TESTNAME}
+
+Suite teardown is executed after `Fatal Error` keyword
+ [Documentation] Tests also Fata Error without a message
+ Check Log Message ${SUITE.teardown.msgs[0]} AssertionError FAIL
=======================================
--- /dev/null
+++ /trunk/atest/testdata/standard_libraries/builtin/fatal_error.txt Thu
May 6 02:04:00 2010
@@ -0,0 +1,15 @@
+***Settings***
+Suite Teardown Fatal Error
+
+***Test Cases***
+
+Test is stopped when `Fatal Error` keyword is used
+ [Documentation] FAIL Faster, Pussycat! Kill! Kill!\n\n
+ ... Also teardown of the parent suite failed.
+ Fatal Error Faster, Pussycat! Kill! Kill!
+ Fail This isn't executed anymore
+
+Subsequent tests are not executed after `Fatal Error` keyword has been used
+ [Documentation] FAIL Test execution is stopped due to a fatal
error\n\n
+ ... Also teardown of the parent suite failed.
+ Fail This isn't executed anymore
=======================================
--- /trunk/src/robot/libraries/BuiltIn.py Wed May 5 15:26:32 2010
+++ /trunk/src/robot/libraries/BuiltIn.py Thu May 6 02:04:00 2010
@@ -118,11 +118,25 @@
class _Verify:
- # Wrappers for robot.asserts
-
def fail(self, msg=None):
- """Fails the test immediately with the given (optional) message."""
- asserts.fail(msg)
+ """Fails the test immediately with the given (optional) message.
+
+ See `Fatal Error` if you need to stop the whole test execution.
+ """
+ raise AssertionError(msg) if msg else AssertionError()
+
+ def fatal_error(self, msg=None):
+ """Stops the whole test execution.
+
+ The test or suite where this keyword is used fails with the
provided
+ message, and subsequent tests fail with a canned message.
+ Possible teardowns will nevertheless be executed.
+
+ See `Fail` if you only want to stop one test case unconditionally.
+ """
+ error = AssertionError(msg) if msg else AssertionError()
+ error.ROBOT_EXIT_ON_FAILURE = True
+ raise error
def should_not_be_true(self, condition, msg=None):
"""Fails if the given condition is true.