Esempio n. 1
0
 def test_result_record_skip_with_json_extra(self):
     record = records.TestResultRecord(self.tn)
     record.test_begin()
     s = signals.TestSkip(self.details, self.json_extra)
     record.test_skip(s)
     self.verify_record(record=record,
                        result=records.TestResultEnums.TEST_RESULT_SKIP,
                        details=self.details,
                        extras=self.json_extra)
Esempio n. 2
0
 def test_result_record_skip_with_float_extra(self):
     record = records.TestResultRecord(self.tn)
     record.test_begin()
     s = signals.TestSkip(self.details, self.float_extra)
     record.test_skip(s)
     self.verify_record(record=record,
                        result=records.TestResultEnums.TEST_RESULT_SKIP,
                        details=self.details,
                        termination_signal_type='TestSkip',
                        extras=self.float_extra)
Esempio n. 3
0
def skip(reason, extras=None):
    """Skip a test.

    Args:
        reason: The reason this test is skipped.
        extras: An optional field for extra information to be included in
            test result.

    Raises:
        signals.TestSkip: Mark a test as skipped.
    """
    raise signals.TestSkip(reason, extras)
Esempio n. 4
0
 def test_is_all_pass(self):
     s = signals.TestPass(self.details, self.float_extra)
     record1 = records.TestResultRecord(self.tn)
     record1.test_begin()
     record1.test_pass(s)
     s = signals.TestSkip(self.details, self.float_extra)
     record2 = records.TestResultRecord(self.tn)
     record2.test_begin()
     record2.test_skip(s)
     tr = records.TestResult()
     tr.add_record(record1)
     tr.add_record(record2)
     tr.add_record(record1)
     self.assertEqual(len(tr.passed), 2)
     self.assertTrue(tr.is_all_pass)
    def create_test_record(self, mobly_test_class):
        """Creates a TestResultRecord for the instrumentation block.

    Args:
      mobly_test_class: string, the name of the Mobly test case
        executing the instrumentation run.

    Returns:
      A TestResultRecord with an appropriate signals exception
      representing the instrumentation test method's result status.
    """
        details = self._get_details()
        extras = self._get_extras()

        tr_record = records.TestResultRecord(
            t_name=self._get_full_name(),
            t_class=mobly_test_class,
        )
        if self._begin_time:
            tr_record.begin_time = self._begin_time

        if self._is_failed():
            tr_record.test_fail(
                e=signals.TestFailure(details=details, extras=extras))
        elif self._status_code in _InstrumentationStatusCodeCategories.SKIPPED:
            tr_record.test_skip(
                e=signals.TestSkip(details=details, extras=extras))
        elif self._status_code in _InstrumentationStatusCodeCategories.PASS:
            tr_record.test_pass(
                e=signals.TestPass(details=details, extras=extras))
        elif self._status_code in _InstrumentationStatusCodeCategories.TIMING:
            if self._error_message:
                tr_record.test_error(
                    e=signals.TestError(details=details, extras=extras))
            else:
                tr_record = None
        else:
            tr_record.test_error(
                e=signals.TestError(details=details, extras=extras))
        if self._known_keys[_InstrumentationKnownStatusKeys.STACK]:
            tr_record.termination_signal.stacktrace = self._known_keys[
                _InstrumentationKnownStatusKeys.STACK]
        return tr_record