samedi 17 mars 2018

Correct way to separate Boost test suites in different files using CLion

I'm trying to use Boost tests in my project in CLion, but I'm having some problems in making tests modular. In Boost documentation there is always only one file with all tests defined below, but as I plan to have many tests this is not good.
What I'd like to have is each test suite in a separate file and a "main" test file to execute all tests inside CLion test environment.

I found a way to do that but it is quite ugly and feels wrong so I'm looking for the right way to do this.

I am currently using this:

// CMakeLists.txt

...

add_executable(all_tests tests/all_tests.cpp ${SOURCES})
target_link_libraries(all_tests my_lib)


// tests/all_tests.cpp

#define BOOST_TEST_MODULE Project Tests
#include <boost/test/included/unit_test.hpp>

#include "Test1.cpp"
#include "Test2.cpp"
...

Aucun commentaire:

Enregistrer un commentaire