예제 #1
0
 def test_print_test_names_with_exception(self):
     mock_test_class = mock.MagicMock()
     mock_cls_instance = mock.MagicMock()
     mock_test_class.return_value = mock_cls_instance
     test_runner._print_test_names(mock_test_class)
     mock_cls_instance.setup_generated_tests.side_effect = Exception(
         'Something went wrong.')
     mock_cls_instance._controller_manager.unregister_controllers.assert_called_once(
     )
예제 #2
0
 def test_print_test_names(self):
     mock_test_class = mock.MagicMock()
     mock_cls_instance = mock.MagicMock()
     mock_test_class.return_value = mock_cls_instance
     test_runner._print_test_names(mock_test_class)
     mock_cls_instance.setup_generated_tests.assert_called_once()
     mock_cls_instance.get_existing_test_names.assert_called_once()
     mock_cls_instance._controller_manager.unregister_controllers.assert_called_once(
     )
예제 #3
0
    def ListTestCases(self):
        '''List test cases.

        Returns:
            List of string, test names.
        '''
        classes = mobly_test_runner._find_test_class()

        with capture_printout.CaptureStdout() as output:
            mobly_test_runner._print_test_names(classes)

        test_names = []

        for line in output:
            if (not line.startswith(LIST_TEST_OUTPUT_START)
                    and line.endswith(LIST_TEST_OUTPUT_END)):
                test_names.append(line)
                tr_record = records.TestResultRecord(line,
                                                     self.test_module_name)
                self.results.requested.append(tr_record)

        return test_names