Skip to content

Add support for multiple C/C++ files containing tests #71

@shanebishop

Description

@shanebishop

Discussed in #54

Originally posted by stefano-p July 21, 2021

I was evaluating this framework and found that is seems not possible to build multiple c test files. So do I have to put all tests in one single module?

This file alone ( test_all.c) compiles and run correctly.

test_all.c

#define CESTER_NO_MAIN
#include <exotic/cester.h>

CESTER_TEST(test1, test_instance,
            cester_assert_equal(NULL, NULL);
)

CESTER_TEST(test_two, test_instance,
    cester_assert_ptr_equal(test_instance, NULL);    
)

CESTER_TEST(test_three, test_instance,
    cester_assert_short_eq(1, 1);    
)

CESTER_BODY(
int main(int argc, char** argv) {
        return CESTER_RUN_ALL_TESTS(argc, argv);
}
)

But as I add a new one (test_my_module1.c) I get some strange linker errors saying that there are:

  • multiple definition of `superTestInstance';
  • multiple definition of `default_color';
  • multiple definition of `hConsole';

I also had to define CESTER_NO_MAIN and CESTER_NO_SIGNAL in order to lower the number of "multiple definition" errors.

test_my_module1.c

#define CESTER_NO_MAIN
#define CESTER_NO_SIGNAL
#include <exotic/cester.h>

CESTER_TEST(test4, test_instance,
            cester_assert_equal(NULL, NULL);
)

Is it possible to spread tests across multiple c files? How?

Please add support for for multiple C/C++ files containing assertions/tests. Ideally it should be possible to build the tests with a single command, and then run the tests with a single command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions