Exemple #1
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
Exemple #2
0
 def test__find_test_class_when_no_test_class(self):
     with self.assertRaises(SystemExit):
         with mock.patch.dict('sys.modules', __main__=mock_controller):
             test_class = test_runner._find_test_class()
Exemple #3
0
 def test__find_test_class_when_multiple_test_classes(self):
     with self.assertRaises(SystemExit):
         with mock.patch.dict('sys.modules',
                              __main__=multiple_subclasses_module):
             test_class = test_runner._find_test_class()
Exemple #4
0
 def test__find_test_class_when_one_test_class(self):
     with mock.patch.dict('sys.modules', __main__=integration_test):
         test_class = test_runner._find_test_class()
         self.assertEqual(test_class, integration_test.IntegrationTest)