Esempio n. 1
0
    def test_single_case_with_error_due_to_failure_to_execute(self):
        cases = [
            (tcp.new_internal_error(error_info.of_message('error message')),
             tcp.Status.INTERNAL_ERROR.name),
            (tcp.new_access_error(AccessErrorType.FILE_ACCESS_ERROR,
                                  error_info.of_message('error message')),
             AccessErrorType.FILE_ACCESS_ERROR.name),
        ]
        for case_result, error_type in cases:
            with self.subTest(case_result_status=case_result.status):
                # ARRANGE #
                expected_xml = suite_xml(attributes={
                    'name': 'suite with error',
                    'tests': '1',
                    'errors': '1',
                    'failures': '0'},
                    test_case_elements=[
                        erroneous_test_case_xml('test case file name',
                                                error_type=error_type,
                                                failure_message=error_message_for_error_info(case_result.error_info))
                    ])
                expected_output = expected_output_from(expected_xml)
                root_suite = test_suite('suite with error', [], [test_case('test case file name')])
                test_suites = [root_suite]
                # ACT #
                actual = execute_with_case_processing_with_constant_result(
                    case_result,
                    root_suite,
                    Path(),
                    test_suites)

                # ASSERT #
                self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
                self.assertEqual(expected_output, replace_xml_variables(actual.stdout))
Esempio n. 2
0
 def test_single_suite_with_test_cases_with_different_result(self):
     # ARRANGE #
     reporter = ExecutionTracingProcessingReporter()
     str_std_out_files = StringStdOutFiles()
     tc_internal_error = test_case_reference_of_source_file(Path('internal error'))
     tc_access_error = test_case_reference_of_source_file(Path('access error'))
     tc_executed = test_case_reference_of_source_file(Path('executed'))
     root = test_suite(
         'root',
         [],
         [
             tc_internal_error,
             tc_access_error,
             tc_executed,
         ])
     test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
         id(tc_internal_error): new_internal_error(error_info.of_message('message')),
         id(tc_access_error): new_access_error(
             tcp.AccessErrorType.SYNTAX_ERROR, error_info.of_message('syntax error')),
         id(tc_executed): new_executed(FULL_RESULT_PASS),
     })
     expected_suites = [
         ExpectedSuiteReporting(root,
                                [
                                    (tc_internal_error, tcp.Status.INTERNAL_ERROR),
                                    (tc_access_error, tcp.Status.ACCESS_ERROR),
                                    (tc_executed, tcp.Status.EXECUTED),
                                ])
     ]
     suite_hierarchy_reader = ReaderThatGivesConstantSuite(root)
     processor = Processor(DUMMY_CASE_PROCESSING,
                           suite_hierarchy_reader,
                           reporter,
                           DepthFirstEnumerator(),
                           lambda config: test_case_processor)
     # ACT #
     exit_code = processor.process(pathlib.Path('root-suite-file'), str_std_out_files.stdout_files)
     # ASSERT #
     check_exit_code_and_empty_stdout(self,
                                      ExecutionTracingRootSuiteReporter.VALID_SUITE_EXIT_CODE,
                                      exit_code,
                                      str_std_out_files)
     ExpectedSuiteReporting.check_list(
         self,
         expected_suites,
         reporter.complete_suite_reporter)
Esempio n. 3
0
 def test_single_suite_with_test_cases_with_different_result(self):
     # ARRANGE #
     reporter = ExecutionTracingProcessingReporter()
     str_std_out_files = StringStdOutFiles()
     tc_internal_error = test_case_reference_of_source_file(
         Path('internal error'))
     tc_access_error = test_case_reference_of_source_file(
         Path('access error'))
     tc_executed = test_case_reference_of_source_file(Path('executed'))
     root = test_suite('root', [], [
         tc_internal_error,
         tc_access_error,
         tc_executed,
     ])
     test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
         id(tc_internal_error):
         new_internal_error(error_info.of_message('message')),
         id(tc_access_error):
         new_access_error(tcp.AccessErrorType.SYNTAX_ERROR,
                          error_info.of_message('syntax error')),
         id(tc_executed):
         new_executed(FULL_RESULT_PASS),
     })
     expected_suites = [
         ExpectedSuiteReporting(root, [
             (tc_internal_error, tcp.Status.INTERNAL_ERROR),
             (tc_access_error, tcp.Status.ACCESS_ERROR),
             (tc_executed, tcp.Status.EXECUTED),
         ])
     ]
     suite_hierarchy_reader = ReaderThatGivesConstantSuite(root)
     processor = Processor(DUMMY_CASE_PROCESSING, suite_hierarchy_reader,
                           reporter, DepthFirstEnumerator(),
                           lambda config: test_case_processor)
     # ACT #
     exit_code = processor.process(pathlib.Path('root-suite-file'),
                                   str_std_out_files.reporting_environment)
     # ASSERT #
     check_exit_code_and_empty_stdout(
         self, ExecutionTracingRootSuiteReporter.VALID_SUITE_EXIT_CODE,
         exit_code, str_std_out_files)
     ExpectedSuiteReporting.check_list(self, expected_suites,
                                       reporter.complete_suite_reporter)
Esempio n. 4
0
    def test_single_case_with_error_due_to_failure_to_execute(self):
        cases = [
            (tcp.new_internal_error(error_info.of_message('error message')),
             tcp.Status.INTERNAL_ERROR.name),
            (tcp.new_access_error(AccessErrorType.FILE_ACCESS_ERROR,
                                  error_info.of_message('error message')),
             AccessErrorType.FILE_ACCESS_ERROR.name),
        ]
        for case_result, error_type in cases:
            with self.subTest(case_result_status=case_result.status):
                # ARRANGE #
                expected_xml = suite_xml(attributes={
                    'name': 'suite with error',
                    'tests': '1',
                    'errors': '1',
                    'failures': '0'},
                    test_case_elements=[
                        erroneous_test_case_xml('test case file name',
                                                error_type=error_type,
                                                failure_message=error_message_for_error_info(case_result.error_info))
                    ])
                expected__assertion = asrt_etree.str_as_xml_equals(expected_xml)
                root_suite = test_suite('suite with error', [], [test_case('test case file name')])
                test_suites = [root_suite]
                # ACT #
                actual = execute_with_case_processing_with_constant_result(
                    case_result,
                    root_suite,
                    Path(),
                    test_suites)

                # ASSERT #
                self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
                expected__assertion.apply_with_message(self,
                                                       replace_xml_variables(actual.stdout),
                                                       'suite xml on stdout')
Esempio n. 5
0
    def test_complex_suite_structure_with_test_cases(self):
        # ARRANGE #
        reporter = ExecutionTracingProcessingReporter()
        str_std_out_files = StringStdOutFiles()
        tc_internal_error_11 = test_case_reference_of_source_file(Path('internal error 11'))
        tc_internal_error_21 = test_case_reference_of_source_file(Path('internal error 21'))
        tc_access_error_1 = test_case_reference_of_source_file(Path('access error A'))
        tc_access_error_12 = test_case_reference_of_source_file(Path('access error 12'))
        tc_executed_11 = test_case_reference_of_source_file(Path('executed 11'))
        tc_executed_12 = test_case_reference_of_source_file(Path('executed 12'))
        tc_executed_1 = test_case_reference_of_source_file(Path('executed 1'))
        tc_executed_2 = test_case_reference_of_source_file(Path('executed 2'))
        tc_executed_root = test_case_reference_of_source_file(Path('executed root'))
        test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
            id(tc_internal_error_11): new_internal_error(error_info.of_message('message A')),
            id(tc_internal_error_21): new_internal_error(error_info.of_message('message B')),
            id(tc_access_error_1): new_access_error(
                tcp.AccessErrorType.SYNTAX_ERROR, error_info.of_message('syntax error')),
            id(tc_access_error_12): new_access_error(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                                                     error_info.of_message('file access error')),
            id(tc_executed_11): new_executed(FULL_RESULT_PASS),
            id(tc_executed_12): new_executed(FULL_RESULT_PASS),
            id(tc_executed_1): new_executed(FULL_RESULT_PASS),
            id(tc_executed_2): new_executed(FULL_RESULT_PASS),
            id(tc_executed_root): new_executed(FULL_RESULT_PASS),
        })
        sub11 = test_suite('11', [], [tc_internal_error_11,
                                      tc_executed_11])
        sub12 = test_suite('12', [], [tc_executed_12,
                                      tc_access_error_12])
        sub1 = test_suite('1', [sub11, sub12], [tc_access_error_1,
                                                tc_executed_1])
        sub21 = test_suite('21', [], [tc_internal_error_21])
        sub2 = test_suite('2', [sub21], [tc_executed_2])
        sub3 = test_suite('2', [], [])
        root = test_suite('root', [sub1, sub2, sub3], [tc_executed_root])

        expected_suites = [
            ExpectedSuiteReporting(sub11, [(tc_internal_error_11, tcp.Status.INTERNAL_ERROR),
                                           (tc_executed_11, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(sub12, [(tc_executed_12, tcp.Status.EXECUTED),
                                           (tc_access_error_12, tcp.Status.ACCESS_ERROR)]),
            ExpectedSuiteReporting(sub1, [(tc_access_error_1, tcp.Status.ACCESS_ERROR),
                                          (tc_executed_1, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(sub21, [(tc_internal_error_21, tcp.Status.INTERNAL_ERROR)]),
            ExpectedSuiteReporting(sub2, [(tc_executed_2, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(sub3, []),
            ExpectedSuiteReporting(root, [(tc_executed_root, tcp.Status.EXECUTED)]),
        ]
        suite_hierarchy_reader = ReaderThatGivesConstantSuite(root)
        processor = Processor(DUMMY_CASE_PROCESSING,
                              suite_hierarchy_reader,
                              reporter,
                              DepthFirstEnumerator(),
                              lambda config: test_case_processor)
        # ACT #
        exit_code = processor.process(pathlib.Path('root-suite-file'), str_std_out_files.stdout_files)
        # ASSERT #
        check_exit_code_and_empty_stdout(self,
                                         ExecutionTracingRootSuiteReporter.VALID_SUITE_EXIT_CODE,
                                         exit_code,
                                         str_std_out_files)
        ExpectedSuiteReporting.check_list(
            self,
            expected_suites,
            reporter.complete_suite_reporter)
Esempio n. 6
0
 def test_reading_error(self):
     result = new_access_error(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                               error_info.of_message('message'))
     self._check(result)
Esempio n. 7
0
 def test_internal_error(self):
     result = new_internal_error(error_info.of_message('message'))
     self._check(result)
Esempio n. 8
0
    def test_complex_suite_structure_with_test_cases(self):
        # ARRANGE #
        reporter = ExecutionTracingProcessingReporter()
        str_std_out_files = StringStdOutFiles()
        tc_internal_error_11 = test_case_reference_of_source_file(
            Path('internal error 11'))
        tc_internal_error_21 = test_case_reference_of_source_file(
            Path('internal error 21'))
        tc_access_error_1 = test_case_reference_of_source_file(
            Path('access error A'))
        tc_access_error_12 = test_case_reference_of_source_file(
            Path('access error 12'))
        tc_executed_11 = test_case_reference_of_source_file(
            Path('executed 11'))
        tc_executed_12 = test_case_reference_of_source_file(
            Path('executed 12'))
        tc_executed_1 = test_case_reference_of_source_file(Path('executed 1'))
        tc_executed_2 = test_case_reference_of_source_file(Path('executed 2'))
        tc_executed_root = test_case_reference_of_source_file(
            Path('executed root'))
        test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
            id(tc_internal_error_11):
            new_internal_error(error_info.of_message('message A')),
            id(tc_internal_error_21):
            new_internal_error(error_info.of_message('message B')),
            id(tc_access_error_1):
            new_access_error(tcp.AccessErrorType.SYNTAX_ERROR,
                             error_info.of_message('syntax error')),
            id(tc_access_error_12):
            new_access_error(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                             error_info.of_message('file access error')),
            id(tc_executed_11):
            new_executed(FULL_RESULT_PASS),
            id(tc_executed_12):
            new_executed(FULL_RESULT_PASS),
            id(tc_executed_1):
            new_executed(FULL_RESULT_PASS),
            id(tc_executed_2):
            new_executed(FULL_RESULT_PASS),
            id(tc_executed_root):
            new_executed(FULL_RESULT_PASS),
        })
        sub11 = test_suite('11', [], [tc_internal_error_11, tc_executed_11])
        sub12 = test_suite('12', [], [tc_executed_12, tc_access_error_12])
        sub1 = test_suite('1', [sub11, sub12],
                          [tc_access_error_1, tc_executed_1])
        sub21 = test_suite('21', [], [tc_internal_error_21])
        sub2 = test_suite('2', [sub21], [tc_executed_2])
        sub3 = test_suite('2', [], [])
        root = test_suite('root', [sub1, sub2, sub3], [tc_executed_root])

        expected_suites = [
            ExpectedSuiteReporting(
                sub11, [(tc_internal_error_11, tcp.Status.INTERNAL_ERROR),
                        (tc_executed_11, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(
                sub12, [(tc_executed_12, tcp.Status.EXECUTED),
                        (tc_access_error_12, tcp.Status.ACCESS_ERROR)]),
            ExpectedSuiteReporting(
                sub1, [(tc_access_error_1, tcp.Status.ACCESS_ERROR),
                       (tc_executed_1, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(
                sub21, [(tc_internal_error_21, tcp.Status.INTERNAL_ERROR)]),
            ExpectedSuiteReporting(sub2,
                                   [(tc_executed_2, tcp.Status.EXECUTED)]),
            ExpectedSuiteReporting(sub3, []),
            ExpectedSuiteReporting(root,
                                   [(tc_executed_root, tcp.Status.EXECUTED)]),
        ]
        suite_hierarchy_reader = ReaderThatGivesConstantSuite(root)
        processor = Processor(DUMMY_CASE_PROCESSING, suite_hierarchy_reader,
                              reporter, DepthFirstEnumerator(),
                              lambda config: test_case_processor)
        # ACT #
        exit_code = processor.process(pathlib.Path('root-suite-file'),
                                      str_std_out_files.reporting_environment)
        # ASSERT #
        check_exit_code_and_empty_stdout(
            self, ExecutionTracingRootSuiteReporter.VALID_SUITE_EXIT_CODE,
            exit_code, str_std_out_files)
        ExpectedSuiteReporting.check_list(self, expected_suites,
                                          reporter.complete_suite_reporter)
Esempio n. 9
0
 def test_reading_error(self):
     result = new_access_error(tcp.AccessErrorType.FILE_ACCESS_ERROR,
                               error_info.of_message('message'))
     self._check(result)
Esempio n. 10
0
 def test_internal_error(self):
     result = new_internal_error(error_info.of_message('message'))
     self._check(result)