Skip to content

Support testing suite nesting #7

@tpecar

Description

@tpecar

Not sure to which degree this applies to the CUTE project itself, but here it goes.

The cgreen unit testing framework, which provides a CUTE compatible reporter, allows nesting of suites.

The example shown here

  • creates a main suite (the create_test_suite() macro uses the name of the caller as suite name), and
  • appends an first_suite and second_suite to it.
#include <cgreen/cgreen.h>

Ensure(first_suite_test) {
    assert_true(1);
}

TestSuite *first_suite() {
    TestSuite *suite = create_test_suite();
    add_test(suite, first_suite_test);
    /* could add more */
    return suite;
}


Ensure(second_suite_test) {
    assert_true(1);
}

TestSuite *second_suite() {
    TestSuite *suite = create_test_suite();
    add_test(suite, second_suite_test);
    /* could add more */
    return suite;
}


int main(int argc, char **argv) {
    TestSuite *suite = create_test_suite();
    add_suite(suite, first_suite());
    add_suite(suite, second_suite());

    TestReporter *reporter = create_cute_reporter();

    return run_test_suite(suite, reporter);
}

This generates the following output

#beginning main 2
#beginning first_suite 1
#starting first_suite_test
#success first_suite_test, 535408 ms OK
#ending first_suite
#beginning second_suite 1
#starting second_suite_test
#success second_suite_test, 535408 ms OK
#ending second_suite
#ending main: 2 passes, 0 failures, 0 exceptions, 1742 ms.

The plugin seems to parse the nesting, but it doesn't display the statistics correctly

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions