a question regarding automatic test module registration
Hi, I'm trying to use the boost unit test framework, and I have a question regarding automatic test module registration and the automatic definition of the init_unit_test_suite() function. I'm organizing unit tests into a range of source files: tests1.cpp tests2.cpp where each file is set up as follows: #define BOOST_TEST_MODULE moduleX #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE(test1) { ... } BOOST_AUTO_TEST_CASE(test2) { ... } and I'm linking this all with -lboost_unit_test_framework-mt -lboost_test_exec_monitor-mt Intersestingly, as soon as I have two or more test module files, I get the following linker error: /usr/include/boost/test/unit_test_suite.hpp:187: multiple definition of `init_unit_test_suite(int, char**)' debug/testGeometry.o:/usr/include/boost/test/unit_test_suite.hpp:187: first defined here This seems to be a bit counter-intuitive - after all, isn't one supposed to be able to use a number of test modules as above? (for me, intuitively, yes :) but if this is not the intended way of using the boost unit test library, how would one go about this using auto-registration? it would be really nice to spare the hassle of manual registration, but still be able to partition test cases into separate modules / files. Akos
Ákos Maróy <akos <at> maroy.hu> writes:
Hi,
I'm trying to use the boost unit test framework, and I have a question regarding automatic test module registration and the automatic definition of the init_unit_test_suite() function.
I'm organizing unit tests into a range of source files:
tests1.cpp tests2.cpp
where each file is set up as follows:
#define BOOST_TEST_MODULE moduleX #include <boost/test/unit_test.hpp>
Only one file should define BOOST_TEST_MODULE, after all - you don't need to repeat the name of your test module twice ;)? Gennadiy
Gennadiy,
Only one file should define BOOST_TEST_MODULE, after all - you don't need to repeat the name of your test module twice ;)?
I see. so there's one test module per unit tast executable. this wasn't clear for me. for the other testX.cpp files, I just use the BOOST_AUTO_TEST_CASE macro, and they are going to be registered, right? Akos
Ákos Maróy <akos <at> maroy.hu> writes:
Gennadiy,
Only one file should define BOOST_TEST_MODULE, after all - you don't need to repeat the name of your test module twice ;)?
I see. so there's one test module per unit tast executable. this wasn't clear for me.
Unit test executable *is* a test module. Test module may include multiple test files.
for the other testX.cpp files, I just use the BOOST_AUTO_TEST_CASE macro, and they are going to be registered, right?
Yes. Gennadiy
participants (2)
-
Gennadiy Rozental
-
Ákos Maróy