示例#1
0
    def test_single_case_that_passes(self):
        cases = [
            FULL_RESULT_PASS,
            FULL_RESULT_XFAIL,
            FULL_RESULT_SKIP,
        ]
        for case_result in cases:
            with self.subTest(case_result_status=case_result.status):
                # ARRANGE #
                expected_xml = suite_xml(attributes={
                    'name': 'suite that passes',
                    'tests': '1',
                    'errors': '0',
                    'failures': '0',
                },
                    test_case_elements=[successful_test_case_xml('test case file name')]
                )
                expected__assertion = asrt_etree.str_as_xml_equals(expected_xml)
                root_suite = test_suite('suite that passes', [], [test_case('test case file name')])
                test_suites = [root_suite]
                # ACT #
                actual = execute_with_case_processing_with_constant_result(
                    tcp.new_executed(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')
示例#2
0
    def test_single_case_with_error(self):
        cases = [
            FULL_RESULT_HARD_ERROR,
            FULL_RESULT_VALIDATE,
            FULL_RESULT_IMPLEMENTATION_ERROR,
        ]
        for case_result 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=case_result.status.name,
                                                failure_message=error_message_for_full_result(case_result))])
                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(
                    tcp.new_executed(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))
示例#3
0
 def test_suite_with_only_single_sub_suite_SHOULD_not_include_root_suite_as_test_suite(self):
     # ARRANGE #
     suite_with_single_case = test_suite('suite with single case', [], [
         test_case('the test case')
     ])
     root_suite = test_suite('root suite file name', [
         suite_with_single_case,
     ], [])
     suites = [
         root_suite,
         suite_with_single_case,
     ]
     # ACT #
     actual = execute_with_case_processing_with_constant_result(tcp.new_executed(FULL_RESULT_PASS),
                                                                root_suite,
                                                                Path(),
                                                                suites)
     # ASSERT #
     expected_xml = _suites_xml([
         suite_xml(attributes={
             'name': 'suite with single case',
             'package': '.',
             'id': '1',
             'tests': '1',
             'errors': '0',
             'failures': '0',
         },
             test_case_elements=[successful_test_case_xml('the test case')]
         ),
     ])
     expected__assertion = asrt_etree.str_as_xml_equals(expected_xml)
     self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
     expected__assertion.apply_with_message(self,
                                            replace_xml_variables(actual.stdout),
                                            'suite xml on stdout')
示例#4
0
    def test_single_case_with_error(self):
        cases = [
            FULL_RESULT_HARD_ERROR,
            FULL_RESULT_VALIDATE,
            FULL_RESULT_INTERNAL_ERROR,
        ]
        for case_result 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=case_result.status.name,
                                                failure_message=error_message_for_full_result(case_result))])
                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(
                    tcp.new_executed(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')
示例#5
0
 def test_suite_with_only_single_sub_suite_SHOULD_not_include_root_suite_as_test_suite(self):
     # ARRANGE #
     suite_with_single_case = test_suite('suite with single case', [], [
         test_case('the test case')
     ])
     root_suite = test_suite('root suite file name', [
         suite_with_single_case,
     ], [])
     suites = [
         root_suite,
         suite_with_single_case,
     ]
     # ACT #
     actual = execute_with_case_processing_with_constant_result(tcp.new_executed(FULL_RESULT_PASS),
                                                                root_suite,
                                                                Path(),
                                                                suites)
     # ASSERT #
     expected_xml = _suites_xml([
         suite_xml(attributes={
             'name': 'suite with single case',
             'package': '.',
             'id': '1',
             'tests': '1',
             'errors': '0',
             'failures': '0',
         },
             test_case_elements=[successful_test_case_xml('the test case')]
         ),
     ])
     expected_output = expected_output_from(expected_xml)
     self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
     self.assertEqual(expected_output, replace_xml_variables(actual.stdout))
示例#6
0
    def test_single_case_that_passes(self):
        cases = [
            FULL_RESULT_PASS,
            FULL_RESULT_XFAIL,
            FULL_RESULT_SKIP,
        ]
        for case_result in cases:
            with self.subTest(case_result_status=case_result.status):
                # ARRANGE #
                expected_xml = suite_xml(attributes={
                    'name': 'suite that passes',
                    'tests': '1',
                    'errors': '0',
                    'failures': '0',
                },
                    test_case_elements=[successful_test_case_xml('test case file name')]
                )
                expected_output = expected_output_from(expected_xml)
                root_suite = test_suite('suite that passes', [], [test_case('test case file name')])
                test_suites = [root_suite]
                # ACT #
                actual = execute_with_case_processing_with_constant_result(
                    tcp.new_executed(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))
示例#7
0
 def test_matches(self):
     cases = [
         NEA(
             'default/skipped',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__SKIPPED),
             expected=sut.result_matches(),
         ),
         NEA(
             'default/pass',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_matches(),
         ),
         NEA(
             'status',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_matches(
                 status=asrt.equals(test_case_processing.Status.EXECUTED)),
         ),
         NEA(
             'error_info',
             actual=test_case_processing.new_internal_error(
                 _ERROR_INFO__WITH_DESCRIPTION),
             expected=sut.result_matches(
                 error_info=asrt.is_instance(ErrorInfo)),
         ),
         NEA(
             'access_error_type',
             actual=test_case_processing.new_access_error(
                 self._AN_ACCESS_ERROR_TYPE, _ERROR_INFO__WITH_DESCRIPTION),
             expected=sut.result_matches(access_error_type=asrt.is_instance(
                 test_case_processing.AccessErrorType)),
         ),
         NEA(
             'execution_result',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_matches(execution_result=asrt.is_instance(
                 test_case_processing.FullExeResult)),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             case.expected.apply_without_message(self, case.actual)
def _suite_executor_for_case_processing_that_unconditionally(execution_result: FullExeResult,
                                                             root_suite: structure.TestSuiteHierarchy,
                                                             std_output_files: StringStdOutFiles,
                                                             root_file_path: Path) -> SuitesExecutor:
    factory = sut.SimpleProgressRootSuiteProcessingReporter()
    execution_reporter = factory.execution_reporter(root_suite, std_output_files.stdout_files, root_file_path)
    case_result = test_case_processing.new_executed(execution_result)
    return processing.SuitesExecutor(execution_reporter, DUMMY_CASE_PROCESSING,
                                     lambda conf: TestCaseProcessorThatGivesConstant(case_result))
示例#9
0
 def test_single_sub_suite_with_test_cases_with_different_results(self):
     # ARRANGE #
     tc_pass = test_case('successful case')
     tc_fail = test_case('failing case')
     tc_error = test_case('erroneous case')
     root_suite = test_suite('suite file name', [], [
         tc_pass,
         tc_fail,
         tc_error,
     ])
     suites = [root_suite]
     test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
         id(tc_pass): tcp.new_executed(FULL_RESULT_PASS),
         id(tc_fail): tcp.new_executed(FULL_RESULT_FAIL),
         id(tc_error): tcp.new_executed(FULL_RESULT_HARD_ERROR),
     })
     # ACT #
     actual = execute_with_case_processing_with_constant_processor(test_case_processor,
                                                                   root_suite,
                                                                   Path(),
                                                                   suites)
     # ASSERT #
     expected_xml = suite_xml(attributes={
         'name': 'suite file name',
         'tests': '3',
         'errors': '1',
         'failures': '1',
     },
         test_case_elements=[
             successful_test_case_xml('successful case'),
             failing_test_case_xml('failing case',
                                   failure_type=FULL_RESULT_FAIL.status.name,
                                   failure_message=error_message_for_full_result(FULL_RESULT_FAIL)),
             erroneous_test_case_xml('erroneous case',
                                     error_type=FULL_RESULT_HARD_ERROR.status.name,
                                     failure_message=error_message_for_full_result(FULL_RESULT_HARD_ERROR)),
         ]
     )
     expected__assertion = asrt_etree.str_as_xml_equals(expected_xml)
     self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
     expected__assertion.apply_with_message(self,
                                            replace_xml_variables(actual.stdout),
                                            'suite xml on stdout')
示例#10
0
 def test_single_sub_suite_with_test_cases_with_different_results(self):
     # ARRANGE #
     tc_pass = test_case('successful case')
     tc_fail = test_case('failing case')
     tc_error = test_case('erroneous case')
     root_suite = test_suite('suite file name', [], [
         tc_pass,
         tc_fail,
         tc_error,
     ])
     suites = [root_suite]
     test_case_processor = TestCaseProcessorThatGivesConstantPerCase({
         id(tc_pass): tcp.new_executed(FULL_RESULT_PASS),
         id(tc_fail): tcp.new_executed(FULL_RESULT_FAIL),
         id(tc_error): tcp.new_executed(FULL_RESULT_HARD_ERROR),
     })
     # ACT #
     actual = execute_with_case_processing_with_constant_processor(test_case_processor,
                                                                   root_suite,
                                                                   Path(),
                                                                   suites)
     # ASSERT #
     expected_xml = suite_xml(attributes={
         'name': 'suite file name',
         'tests': '3',
         'errors': '1',
         'failures': '1',
     },
         test_case_elements=[
             successful_test_case_xml('successful case'),
             failing_test_case_xml('failing case',
                                   failure_type=FULL_RESULT_FAIL.status.name,
                                   failure_message=error_message_for_full_result(FULL_RESULT_FAIL)),
             erroneous_test_case_xml('erroneous case',
                                     error_type=FULL_RESULT_HARD_ERROR.status.name,
                                     failure_message=error_message_for_full_result(FULL_RESULT_HARD_ERROR)),
         ]
     )
     expected_output = expected_output_from(expected_xml)
     self.assertEqual(sut.UNCONDITIONAL_EXIT_CODE, actual.exit_code)
     self.assertEqual(expected_output, replace_xml_variables(actual.stdout))
def _suite_executor_for_case_processing_that_unconditionally(
        execution_result: FullExeResult,
        root_suite: structure.TestSuiteHierarchy,
        std_output_files: StringStdOutFiles,
        root_file_path: Path) -> SuitesExecutor:
    factory = sut.SimpleProgressRootSuiteProcessingReporter()
    execution_reporter = factory.execution_reporter(
        root_suite, std_output_files.reporting_environment, root_file_path)
    case_result = test_case_processing.new_executed(execution_result)
    return processing.SuitesExecutor(
        execution_reporter, DUMMY_CASE_PROCESSING,
        lambda conf: TestCaseProcessorThatGivesConstant(case_result))
示例#12
0
 def test_not_matches(self):
     cases = [
         NEA(
             'default/invalid type',
             actual='not a result',
             expected=sut.result_matches(),
         ),
         NEA(
             'status',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_matches(status=asrt.equals(
                 test_case_processing.Status.ACCESS_ERROR)),
         ),
         NEA(
             'error_info',
             actual=test_case_processing.new_internal_error(
                 _ERROR_INFO__WITH_DESCRIPTION),
             expected=sut.result_matches(error_info=sut.error_info_matches(
                 description=asrt.is_none)),
         ),
         NEA(
             'access_error_type',
             actual=test_case_processing.new_access_error(
                 test_case_processing.AccessErrorType.FILE_ACCESS_ERROR,
                 _ERROR_INFO__WITH_DESCRIPTION),
             expected=sut.result_matches(access_error_type=asrt.is_(
                 test_case_processing.AccessErrorType.PRE_PROCESS_ERROR)),
         ),
         NEA(
             'execution_result',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_matches(
                 execution_result=asrt_full_exe_result.is_xpass()),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             assert_that_assertion_fails(case.expected, case.actual)
示例#13
0
 def apply(self, test_case: processing.TestCaseFileReference) -> processing.Result:
     try:
         try:
             a_test_case_doc = self._accessor.apply(test_case)
         except AccessorError as ex:
             return processing.Result(processing.Status.ACCESS_ERROR,
                                      error_info=ex.error_info,
                                      error_type=ex.error)
         full_result = self._executor.apply(test_case.file_path,
                                            a_test_case_doc)
         return processing.new_executed(full_result)
     except Exception as ex:
         return processing.new_internal_error(ErrorInfo(error_description.of_exception(ex)))
示例#14
0
 def apply(
         self,
         test_case: processing.TestCaseFileReference) -> processing.Result:
     try:
         try:
             a_test_case_doc = self._accessor.apply(test_case)
         except AccessorError as ex:
             return processing.Result(processing.Status.ACCESS_ERROR,
                                      error_info=ex.error_info,
                                      error_type=ex.error)
         full_result = self._executor.apply(test_case.file_path,
                                            a_test_case_doc)
         return processing.new_executed(full_result)
     except Exception as ex:
         return processing.new_internal_error(
             ErrorInfo(error_description.of_exception(ex)))
示例#15
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)
示例#16
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)
示例#17
0
 def test_not_matches(self):
     cases = [
         NEA(
             'not an access error',
             actual=test_case_processing.new_executed(
                 _FULL_EXE_RESULT__PASS),
             expected=sut.result_is_access_error(
                 AccessErrorType.PRE_PROCESS_ERROR),
         ),
         NEA(
             'unexpected access error',
             actual=test_case_processing.new_access_error(
                 AccessErrorType.FILE_ACCESS_ERROR,
                 _ERROR_INFO__WITH_DESCRIPTION),
             expected=sut.result_is_access_error(
                 AccessErrorType.PRE_PROCESS_ERROR),
         ),
     ]
     for case in cases:
         with self.subTest(case.name):
             assert_that_assertion_fails(case.expected, case.actual)
示例#18
0
 def test_executed__pass(self):
     result = new_executed(FULL_RESULT_PASS)
     self._check(result)
示例#19
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)
 def apply(self, test_case: TestCaseFileReference) -> Result:
     self.recording_media.append(test_case)
     return new_executed(FULL_RESULT_PASS)
示例#21
0
 def apply(self, test_case: TestCaseFileReference) -> Result:
     self.recording_media.append(test_case)
     return new_executed(FULL_RESULT_PASS)
示例#22
0
 def test_executed__skipped(self):
     result = new_executed(new_skipped())
     self._check(result)
示例#23
0
 def test_executed__pass(self):
     result = new_executed(FULL_RESULT_PASS)
     self._check(result)
示例#24
0
 def test_executed__skipped(self):
     result = new_executed(new_skipped())
     self._check(result)
示例#25
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)