Revision: 4580
Author: jussi.ao.malinen
Date: Wed Feb  2 02:42:09 2011
Log: Tests and implementation to defect which prevented fatal errors in suite setup from being fatal to other suites.

Update issue 763
Status: Done
Owner: jussi.ao.malinen
Labels: Target-2.5.6

Tests and implementation done.

http://code.google.com/p/robotframework/source/detail?r=4580

Added:
 /trunk/atest/testdata/running/fatal_exception_suite_setup
/trunk/atest/testdata/running/fatal_exception_suite_setup/01__suite_setup.txt /trunk/atest/testdata/running/fatal_exception_suite_setup/02__irrelevant.txt
Modified:
 /trunk/atest/robot/running/fatal_exception.txt
 /trunk/src/robot/running/fixture.py
 /trunk/src/robot/running/runerrors.py
 /trunk/utest/running/test_suite_errors.py

=======================================
--- /dev/null
+++ /trunk/atest/testdata/running/fatal_exception_suite_setup/01__suite_setup.txt Wed Feb 2 02:42:09 2011
@@ -0,0 +1,9 @@
+*** Settings ***
+Library  Exceptions
+Suite Setup  Exit On Failure
+Suite Teardown  Log  Tearing down 1
+
+*** Test Cases ***
+Test That Should Not Be Run 1
+    [Documentation]  FAIL  Setup of the parent suite failed.
+    Fail  This should not be executed
=======================================
--- /dev/null
+++ /trunk/atest/testdata/running/fatal_exception_suite_setup/02__irrelevant.txt Wed Feb 2 02:42:09 2011
@@ -0,0 +1,14 @@
+*** Settings ***
+Library      NonExisting
+Resource     NotEither.txt
+Variables    NotHere.py
+Suite Teardown  Log  Tearing down 2
+
+*** Test Cases ***
+Test That Should Not Be Run 2.1
+    [Documentation]  FAIL  Test execution is stopped due to a fatal error
+    No operation
+
+Test That Should Not Be Run 2.2
+    [Documentation]  FAIL  Test execution is stopped due to a fatal error
+    No operation
=======================================
--- /trunk/atest/robot/running/fatal_exception.txt      Fri Dec  3 01:42:43 2010
+++ /trunk/atest/robot/running/fatal_exception.txt      Wed Feb  2 02:42:09 2011
@@ -26,6 +26,26 @@
 Skip Imports On Exit
     Previous test should have passed  Multiple Suite Aware Exiting
     Should be empty  ${ERRORS.messages}
+
+Multiple Suite Aware Exiting From Suite Setup
+    Run Tests  ${EMPTY}  running/fatal_exception_suite_setup/
+    Check Test Case  Test That Should Not Be Run 1
+    ${ts1} =  Get Test Suite  Suite Setup
+    Should End With  ${ts1.teardown.msgs[0].message}  Tearing down 1
+    Check Test Case  Test That Should Not Be Run 2.1
+    Check Test Case  Test That Should Not Be Run 2.2
+    ${ts2} =  Get Test Suite  Irrelevant
+    Should Be Equal  ${ts2.teardown}  ${None}
+
+Multiple Suite Aware Exiting From Suite Setup With Skip Teardowns
+ Run Tests --runmode SkipTeardownOnExit running/fatal_exception_suite_setup/
+    Check Test Case  Test That Should Not Be Run 1
+    ${ts1} =  Get Test Suite  Suite Setup
+    Should Be Equal  ${ts1.teardown}  ${None}
+    Check Test Case  Test That Should Not Be Run 2.1
+    Check Test Case  Test That Should Not Be Run 2.2
+    ${ts2} =  Get Test Suite  Irrelevant
+    Should Be Equal  ${ts2.teardown}  ${None}

 Fatal Exception and Runmode Exit on Failure
Run Tests --runmode exitonfailure running/fatal_exception/01__python_library_kw.txt
=======================================
--- /trunk/src/robot/running/fixture.py Tue Sep 21 08:05:26 2010
+++ /trunk/src/robot/running/fixture.py Wed Feb  2 02:42:09 2011
@@ -64,7 +64,7 @@
     def __init__(self, suite):
         self._suite = suite
     def notify(self, error):
-        self._suite.run_errors.suite_setup_err(unicode(error))
+        self._suite.run_errors.suite_setup_err(error)


 class _TestListener(object):
=======================================
--- /trunk/src/robot/running/runerrors.py       Fri Dec  3 01:42:43 2010
+++ /trunk/src/robot/running/runerrors.py       Wed Feb  2 02:42:09 2011
@@ -74,13 +74,15 @@
                 return True
         return False

-    def suite_init_err(self, err):
-        self._current_init_err = err
+    def suite_init_err(self, error_message):
+        self._current_init_err = error_message

     def setup_executed(self):
         self._current_suite_setup_executed = True

     def suite_setup_err(self, err):
+        if err.exit:
+            self._exit_fatal = True
         self._current_setup_err = unicode(err)

     def suite_error(self):
=======================================
--- /trunk/utest/running/test_suite_errors.py   Wed May  5 00:39:39 2010
+++ /trunk/utest/running/test_suite_errors.py   Wed Feb  2 02:42:09 2011
@@ -1,6 +1,7 @@
 import unittest
 from robot.running.runerrors import SuiteRunErrors
 from robot.utils.asserts import assert_true, assert_false
+from robot.errors import ExecutionFailed


 class TestSuiteRunErrors(unittest.TestCase):
@@ -17,12 +18,12 @@
         self._setup_and_teardown_disallowed()

     def test_teardown_executed_after_setup_errs(self):
-        self.errs.suite_setup_err('Terriblesness occured!')
+ self.errs.suite_setup_err(ExecutionFailed('Terriblesness occured!'))
         self.errs.setup_executed()
         assert_true(self.errs.is_suite_teardown_allowed())

     def test_higher_level_setup_err_prevents_all_lower_level_setups(self):
-        self.errs.suite_setup_err('Terriblesness occured!')
+ self.errs.suite_setup_err(ExecutionFailed('Terriblesness occured!'))
         self.errs.start_suite()
         self._setup_and_teardown_disallowed()
         self.errs.end_suite()
@@ -37,7 +38,7 @@

     def test_sibling_errors_dont_affect_each_other(self):
         self.errs.start_suite()
-        self.errs.suite_setup_err('Terriblesness occured!')
+ self.errs.suite_setup_err(ExecutionFailed('Terriblesness occured!'))
         self.errs.start_suite()
         self._setup_and_teardown_disallowed()
         self.errs.end_suite()
@@ -55,7 +56,6 @@

     def test_teardown_is_run_after_setup_called(self):
         self.errs.start_suite()
-        self.errs.suite_setup_err(None)
         self.errs.setup_executed()
         self.errs.test_failed(exit=True)
         assert_true(self.errs.is_suite_teardown_allowed())

Reply via email to