Exemple #1
0
class TestRunnerNotificationTest(unittest.TestCase):
    def setUp(self):
        self.listener_mock = mock(TestRunListener)
        self.test_definition_mock = mock(TestDefinition)
        self.test_definition_mock.givens = {}
        self.suite = [self.test_definition_mock]

        self.injector_mock = mock(TestInjector)
        self.test_result_mock = mock(TestResult)
        when(self.injector_mock).execute_test(self.test_definition_mock).thenReturn([self.test_result_mock])

        self.test_runner = TestRunner()
        self.test_runner._injector = self.injector_mock
        self.test_runner.add_test_run_listener(self.listener_mock)

    def test_ensure_that_before_suite_is_called(self):
        self.test_runner.run_tests(self.suite)
        verify(self.listener_mock).before_suite(self.suite)

    def test_ensure_that_before_test_is_called(self):
        self.test_runner.run_tests(self.suite)
        verify(self.listener_mock).before_test(self.test_definition_mock)

    def test_ensure_that_after_test_is_called(self):
        self.test_runner.run_tests(self.suite)
        verify(self.listener_mock).after_test(any_value(list))

    def test_ensure_that_after_suite_is_called(self):
        self.test_runner.run_tests(self.suite)
        verify(self.listener_mock).after_suite(any_value(TestSuiteResult))
def execute_tests_matching(logger, test_source, module_glob):
    test_module_names = discover_modules_matching(test_source, module_glob)
    test_modules = import_modules(test_module_names)

    test_collector = TestCollector()

    for test_module in test_modules:
        test_collector.collect_tests(test_module)

    test_runner = TestRunner()
    test_runner.add_test_run_listener(TestListener(logger))
    return test_runner.run_tests(test_collector.test_suite)
def execute_tests(logger, test_source, suffix):
    test_module_names = discover_modules(test_source, suffix)
    test_modules = import_modules(test_module_names)

    test_collector = TestCollector()

    for test_module in test_modules:
        test_collector.collect_tests(test_module)

    test_runner = TestRunner()
    test_runner.add_test_run_listener(TestListener(logger))
    return test_runner.run_tests(test_collector.test_suite)
Exemple #4
0
class TestRunnerExecutionTest(unittest.TestCase):
    def setUp(self):
        self.injector_mock = mock(TestInjector)

        self.test_runner = TestRunner()
        self.test_runner._injector = self.injector_mock

    def test_should_execute_test_function_when_running_test(self):
        test_definition_mock = mock(TestDefinition)
        when(self.injector_mock).execute_test(test_definition_mock).thenReturn(mock(TestResult))

        self.test_runner.run_test([test_definition_mock])

        when(self.injector_mock).execute_test(test_definition_mock)
Exemple #5
0
    def setUp(self):
        self.listener_mock = mock(TestRunListener)
        self.test_definition_mock = mock(TestDefinition)
        self.test_definition_mock.givens = {}
        self.suite = [self.test_definition_mock]

        self.injector_mock = mock(TestInjector)
        self.test_result_mock = mock(TestResult)
        when(self.injector_mock).execute_test(self.test_definition_mock).thenReturn([self.test_result_mock])

        self.test_runner = TestRunner()
        self.test_runner._injector = self.injector_mock
        self.test_runner.add_test_run_listener(self.listener_mock)
Exemple #6
0
    def setUp(self):
        self.injector_mock = mock(TestInjector)

        self.test_runner = TestRunner()
        self.test_runner._injector = self.injector_mock