Repository navigation
Record the class termination signal in TestClassInfoRecord - #1071
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances test execution tracking and reporting in Mobly by expanding TestClassInfoRecord to capture detailed class-level test results, counts, and termination signals. It also refactors the test class and suite runner lifecycles to ensure proper cleanup and accurate reporting under various failure scenarios, supported by comprehensive unit tests. The review feedback highlights two key improvements: preventing the suppression of primary termination errors by cleanup exceptions in base_test.py, and ensuring PEP 8 compliance in records.py by explicitly returning None in property getters.
…n exception handling
* TestClassInfoRecord no longer carries Requested/Executed/Passed/Failed/ Skipped/Error counts; it keeps Result and the termination signal. * run() keeps _pre_run, test-name resolution and _get_test_methods outside the try block as before, so no setup_class_reached flag is needed and _teardown_class() is always the finalizer. * Remove the summary_writer None-guards; summary_writer is always set by TestRunner, consistent with the other dump call sites.
* class_end(results, e=None): derive the termination signal from e or the first class-stage error record, and the result from results.is_all_pass in one short decision chain; drop the four pass-through properties and build to_dict as a literal. * Replace _get_eventually_passing_retry_record_ids with _eventually_passing_retries returning the records themselves. * In run(), whatever escapes _teardown_class is recorded as the terminator, with no precedence special-casing.
|
Pushed a simplification pass: |
* Result is derived from TestResult alone: not all-pass -> ERROR if any error record else FAIL; otherwise PASS unless only skips -> SKIP. No signal-type inspection. * to_dict uses TestResultEnums directly instead of 1:1 KEY_ aliases. * _count_eventually_passing_retries is back to its original form. * TestSkip in setup_class is out of scope for this PR; removed with its test.
The result of a class is already fully described by its test records and TestResult; computing it again at the class level duplicated that logic. class_end(e=None) now only stores the terminating signal.
Summary
Records the signal that terminated a test class in
TestClassInfoRecord(Type: TestClassInfo):mobly/records.py:class_end(e=None)stores the terminating exception orTestSignalas anExceptionRecord, andto_dictaddsDetails,Termination Signal Type,StacktraceandExtrasnext to the existing timestamps. Nothing is derived from the test records; counts and pass/fail state stay inTestResult.mobly/base_test.py:run()passes theTestAbortClass/TestAbortAllsignal, or whatever exception escapes the class body orteardown_class, toclass_end._pre_run()now resets and checksexpects.recorderlike_setup_class()does, soexpects.expect_*failures inpre_runare recorded as class errors instead of being lost.