Exemplo n.º 1
0
def run_single_test(logger, project, reports_dir, test):
    name, _ = os.path.splitext(os.path.basename(test))
    logger.info("Running integration test %s", name)
    env = prepare_environment(project)
    test_time = Timer.start()
    return_code = execute_command((sys.executable, test), os.path.join(reports_dir, name), env)
    test_time.stop()
    report_item = {"test": name, "test_file": test, "time": test_time.get_millis(), "success": True}
    if return_code != 0:
        logger.error("Integration test failed: %s", test)
        report_item["success"] = False

    return report_item
Exemplo n.º 2
0
    def execute_task (self, task, **keywordArguments):
        self.assert_dependencies_resolved()
        
        self.logger.debug("Executing task '%s'", 
                          task.name)
        
        timer = Timer.start()
        number_of_actions = 0
        
        for action in self._execute_before[task.name]:
            if self.execute_action(action, keywordArguments):
                number_of_actions += 1
        
        task.execute(self.logger, keywordArguments)

        for action in self._execute_after[task.name]:
            if self.execute_action(action, keywordArguments):
                number_of_actions += 1

        timer.stop()
        return TaskExecutionSummary(task.name, number_of_actions, timer.get_millis())
Exemplo n.º 3
0
def run_integration_tests(project, logger):
    reports_dir = prepare_reports_directory(project)

    test_failed = 0
    tests_executed = 0
    report_items = []

    total_time = Timer.start()

    for test in discover_integration_tests(
        project.expand_path("$dir_source_integrationtest_python"), project.expand("$integrationtest_file_suffix")
    ):

        report_item = run_single_test(logger, project, reports_dir, test)
        report_items.append(report_item)

        if not report_item["success"]:
            test_failed += 1

        tests_executed += 1

    total_time.stop()

    test_report = {
        "time": total_time.get_millis(),
        "success": test_failed == 0,
        "num_of_tests": tests_executed,
        "tests_failed": test_failed,
        "tests": report_items,
    }

    project.write_report("integrationtest.json", render_report(test_report))

    logger.info("Executed %d integration tests.", tests_executed)
    if test_failed:
        raise BuildFailedException("Integration test(s) failed.")
Exemplo n.º 4
0
 def test_should_return_number_of_millis (self):
     timer = Timer.start()
     time.sleep(1)
     timer.stop()
     self.assertTrue(timer.get_millis() > 0)
Exemplo n.º 5
0
 def test_should_raise_exception_when_fetching_millis_of_running_timer (self):
     timer = Timer.start()
     self.assertRaises(PythonbuilderException, timer.get_millis)
Exemplo n.º 6
0
 def test_ensure_that_start_starts_timer (self):
     timer = Timer.start()
     self.assertTrue(timer.start_time > 0)
     self.assertFalse(timer.end_time)