Ejemplo n.º 1
0
int run_single_test(TestSuite *suite, char *name, TestReporter *reporter) {
	int success = 0;
    run_named_test(suite, name, reporter);
	success = (reporter->failures == 0);
	clean_up_test_run(suite, reporter);
	return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
Ejemplo n.º 2
0
int run_single_test(TestSuite *suite, const char *name, TestReporter *reporter) {
    int success;
    if (per_test_timeout_defined()) {
        validate_per_test_timeout_value();
    }

    setup_reporting(reporter);
    run_named_test(suite, name, reporter);
    success = (reporter->failures == 0);
    return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
Ejemplo n.º 3
0
static void run_named_test(TestSuite *suite, const char *name, TestReporter *reporter) {
    int i;
    (*reporter->start_suite)(reporter, suite->name, count_tests(suite));
    for (i = 0; i < suite->size; i++) {
        if (suite->tests[i].type == test_function) {
            if (strcmp(suite->tests[i].name, name) == 0) {
                run_test_in_the_current_process(suite, suite->tests[i].Runnable.test, reporter);
            }
        } else if (has_test(suite->tests[i].Runnable.suite, name)) {
            (*suite->setup)();
            run_named_test(suite->tests[i].Runnable.suite, name, reporter);
            (*suite->teardown)();
        }
    }
    send_reporter_completion_notification(reporter);
    (*reporter->finish_suite)(reporter, suite->filename, suite->line);
}
Ejemplo n.º 4
0
static void run_named_test(TestSuite *suite, const char *name, TestReporter *reporter) {
    int i;
    uint32_t test_duration;
    uint32_t test_starting_milliseconds = cgreen_time_get_current_milliseconds();

    (*reporter->start_suite)(reporter, suite->name, count_tests(suite));
    for (i = 0; i < suite->size; i++) {
        if (suite->tests[i].type == test_function) {
            if (strcmp(suite->tests[i].name, name) == 0) {
                run_test_in_the_current_process(suite, suite->tests[i].Runnable.test, reporter);
            }
        } else if (has_test(suite->tests[i].Runnable.suite, name)) {
            (*suite->setup)();
            run_named_test(suite->tests[i].Runnable.suite, name, reporter);
            (*suite->teardown)();
        }
    }

    test_duration = cgreen_time_duration_in_milliseconds(test_starting_milliseconds,
                                                                  cgreen_time_get_current_milliseconds());

    send_reporter_completion_notification(reporter);
    (*reporter->finish_suite)(reporter, suite->filename, suite->line, test_duration);
}