Multiple suites run through the same SRunner

Check Tutorial
Prev | Chapter 4. Advanced Features | Next

# 4.4. Multiple suites run through the same SRunner

In a large program, it will be convenient to create multiple suites, each testing a module of the program. While one can create several test programs, each running one Suite, it may be convenient to create one main test program, and use it to run multiple suites. The Check test suite provides an example of how to do this. The main testing program is called check_check, and has a header file that declares suite creation functions for all the module tests:

    Suite *make_sub_suite(void);
    Suite *make_sub2_suite(void);
    Suite *make_master_suite(void);
    Suite *make_list_suite(void);
    Suite *make_msg_suite(void);
    Suite *make_log_suite(void);

The function srunner_add_suite is used to add additional suites to an SRunner. Here is the code to setup and run the SRunner in the main function:

    SRunner *sr;
    sr = srunner_create(make_master_suite());
    srunner_add_suite(sr, make_list_suite());
    srunner_add_suite(sr, make_msg_suite());
    srunner_add_suite(sr, make_log_suite());

Prev | Home | Next
Test fixtures | Up | Testing signal handling