
On Sun, Jul 19, 2009 at 12:42:36AM +0000, Gennadiy Rozental wrote:
Note though that you can combine both manually and automatically registered test units inside the same test module, thus all other test units you can register automatically.
That's neat. How can I specify the hierarchy of different suites? Say, I have one master suite and would like to create a hierarchical tree structures of suites, with tests being the leaves: 0: master / \ 1: s1 s2 / \ 2: t_1..n s3 \ 3: t_1..n I assume I cannot switch between automatic and manual registration within one compilation unit. How could I achieve such a structure then? Here is the example again. First, the master test suite (test1.cc): #define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> void test() { BOOST_CHECK_EQUAL(true, false); BOOST_REQUIRE_EQUAL(1, 1); } bool init_unit_test() { boost::unit_test::test_suite* ts = BOOST_TEST_SUITE("test suite"); ts->add(BOOST_TEST_CASE(&test)); boost::unit_test::framework::master_test_suite().add(ts); return true; } int main(int argc, char* argv[]) { return ::boost::unit_test::unit_test_main(&init_unit_test, argc, argv); } Then, I would like to add child suite automatically (test2.cc): #define BOOST_TEST_MODULE foo test suite #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_SUITE(foo_suite) BOOST_AUTO_TEST_CASE(foo) { BOOST_REQUIRE_EQUAL(42, 43); } BOOST_AUTO_TEST_SUITE_END() When I compile them via g++ test{1,2}.cc -lboost_unit_test_framework-mt the output looks like this: Running 2 test cases... test2.cc:8: fatal error in "foo": critical check 42 == 43 failed [42 != 43] test1.cc:6: error in "test": check true == false failed [true != false] *** 2 failures detected in test suite "Master Test Suite" This looks to me that test foo is part of the Master Test Suite, or am I mistaken? Matthias -- Matthias Vallentin vallentin@icsi.berkeley.edu http://www.icir.org/matthias