diff options
author | Ang Li <angli@google.com> | 2018-06-12 14:24:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-12 14:24:20 -0700 |
commit | 63b8e3fe7707722ade557aac6917e3fd1cd54b45 (patch) | |
tree | fecb2df89c2f05698ce07e066a8d74f69bc2f0ee /mobly/base_test.py | |
parent | c76dc8dfe2251d49e6aef1c83d4a9423835aa304 (diff) | |
download | mobly-63b8e3fe7707722ade557aac6917e3fd1cd54b45.tar.gz |
Fix behaviors of `abort_all` in procedural functions. (#461)
* `abort_all` should skip remaining tests in a class just like `abort_class`.
* A record for `setup_class` should exist if `setup_class` failed and
`abort_all` is called in `on_fail`
* Handle the case of calling `abort_all` in `teardown_class`.
Diffstat (limited to 'mobly/base_test.py')
-rw-r--r-- | mobly/base_test.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mobly/base_test.py b/mobly/base_test.py index 9a2c263..0a2dd13 100644 --- a/mobly/base_test.py +++ b/mobly/base_test.py @@ -190,6 +190,9 @@ class BaseTestClass(object): record.test_begin() try: self.teardown_class() + except signals.TestAbortAll as e: + setattr(e, 'results', self.results) + raise except Exception as e: logging.exception('Error encountered in teardown_class.') record.test_error(e) @@ -636,10 +639,10 @@ class BaseTestClass(object): # Fail the class and skip all tests. logging.exception('Error in setup_class %s.', self.TAG) class_record.test_error(e) - self._exec_procedure_func(self._on_fail, class_record) self.results.add_class_error(class_record) self.summary_writer.dump(class_record.to_dict(), records.TestSummaryEntryType.RECORD) + self._exec_procedure_func(self._on_fail, class_record) self._skip_remaining_tests(e) return self.results # Run tests in order. @@ -651,6 +654,8 @@ class BaseTestClass(object): self._skip_remaining_tests(e) return self.results except signals.TestAbortAll as e: + e.details = 'All remaining tests aborted due to: %s' % e.details + self._skip_remaining_tests(e) # Piggy-back test results on this exception object so we don't lose # results from this test class. setattr(e, 'results', self.results) |