Creating a test file with mutilple test suites
I would link to have one file that has multiple test suites. Right now I have one test suite for all the various tests. I tried to find an example of what I want to do on the boost.org site. There was nothing close to what I wanted. If such a page exists its not easy to find. The close I came to was to create a test_suite for each group and add the test. That is as far as I have gotten. I did find an exampe that use BOOST_AUTO_TEST_CASE but there was only one test suite in it. Here is what I have so far. Is there plans to have a more comprehensive documentation on how to use the boost test library? Can users provide more examples? Stephen BOOST_AUTO_TEST_CASE(test_result_reports) { // test_suite* // init_unit_test_suite ( int, char** ) // { test_suite* test1 = BOOST_TEST_SUITE ("Memory Map constructors"); // Allow Memory_Map to allocate our memory at any location test1->add ( BOOST_TEST_CASE ( &test_default_constructor ) ); test_suite* test2 = BOOST_TEST_SUITE ("Memory Map seek (pass)"); test2->add ( BOOST_TEST_CASE ( &test_seek_PASS_LOW_SEEK ) ); test2->add ( BOOST_TEST_CASE ( &test_seek_PASS_HIGH_SEEK ) ); test_suite* test3 = BOOST_TEST_SUITE ("Memory Map seek (fail)"); test3->add ( BOOST_TEST_CASE ( &test_seek_FAIL_HIGH_SEEK ) ); test3->add ( BOOST_TEST_CASE ( &test_read_FAIL_EMPTY_READ ) ); test_suite* test4 = BOOST_TEST_SUITE ("Memory Map copy"); test4->add ( BOOST_TEST_CASE ( &test_copy ) ); test_suite* test5 = BOOST_TEST_SUITE ("Memory Map read tests"); test5->add ( BOOST_TEST_CASE ( &test_uint8_read ) ); test5->add ( BOOST_TEST_CASE ( &test_uint16_read ) ); test5->add ( BOOST_TEST_CASE ( &test_uint32_read ) ); test5->add ( BOOST_TEST_CASE ( &test_uint64_read ) ); test_suite* test6 = BOOST_TEST_SUITE ("Memory Map address tests"); test6->add ( BOOST_TEST_CASE ( &test_seek_ADDRESS_PASS_LOW ) ); test6->add ( BOOST_TEST_CASE ( &test_seek_ADDRESS_PASS_HIGH ) ); test6->add ( BOOST_TEST_CASE ( &test_seek_ADDRESS_FAIL_LOW ) ); test6->add ( BOOST_TEST_CASE ( &test_seek_ADDRESS_FAIL_HIGH ) ); test_suite* test7 = BOOST_TEST_SUITE ("Memory Map empty name"); test7->add ( BOOST_TEST_CASE ( &test_empty_name ) ); test_suite* test8 = BOOST_TEST_SUITE ("Memory Map subset"); test8->add ( BOOST_TEST_CASE ( &test_subset ) ); //return test; }
"Stephen Torri"
I would link to have one file that has multiple test suites. Right now I have one test suite for all the various tests. I tried to find an example of what I want to do on the boost.org site. There was nothing close to what I wanted. If such a page exists its not easy to find. The close I came to was to create a test_suite for each group and add the test. That is as far as I have gotten. I did find an exampe that use BOOST_AUTO_TEST_CASE but there was only one test suite in it. Here is what I have so far. Is there plans to have a more comprehensive documentation on how to use the boost test library? Can users provide more examples?
You can do it using both manual and automated registration faculties. Here
is one example using auto-registration:
unit_test_example_04.cpp:
#define BOOST_TEST_MODULE Unit_test_example_04
#include
On Wed, 2007-05-23 at 00:17 -0400, Gennadiy Rozental wrote:
unit_test_example_04.cpp:
#define BOOST_TEST_MODULE Unit_test_example_04 #include
//____________________________________________________________________________//
// automatically registered test cases could be organized in test suites BOOST_AUTO_TEST_SUITE( my_suite1 );
BOOST_AUTO_TEST_CASE( my_test1 ) { BOOST_CHECK( 2 == 1 ); }
//____________________________________________________________________________//
// this test case belongs to suite1 test suite BOOST_AUTO_TEST_CASE( my_test2 ) { int i = 0;
BOOST_CHECK_EQUAL( i, 2 );
BOOST_CHECK_EQUAL( i, 0 ); }
BOOST_AUTO_TEST_SUITE_END();
//____________________________________________________________________________//
// this test case belongs to master test suite BOOST_AUTO_TEST_CASE( my_test3 ) { int i = 0;
BOOST_CHECK_EQUAL( i, 0 ); }
//____________________________________________________________________________//
BOOST_AUTO_TEST_SUITE( my_suite2 );
// this test case belongs to suite2 test suite BOOST_AUTO_TEST_CASE( my_test4 ) { int i = 0;
BOOST_CHECK_EQUAL( i, 1 ); }
BOOST_AUTO_TEST_SUITE_END();
//____________________________________________________________________________//
// EOF
If you need you can have hierarchy of any depth.
Gennadiy
I could not see the following files in the web documentation since their link is broken. Who should I tell? http://www.boost.org/libs/test/example/unit_test_example1.cpp http://www.boost.org/libs/test/example/unit_test_example2.cpp http://www.boost.org/libs/test/example/unit_test_example3.cpp http://www.boost.org/libs/test/example/unit_test_example4.cpp http://www.boost.org/libs/test/example/unit_test_example5.cpp Thanks for the help. Stephen
Stephen Torri wrote:
unit_test_example_04.cpp: [...] I could not see the following files in the web documentation since their
On Wed, 2007-05-23 at 00:17 -0400, Gennadiy Rozental wrote: link is broken. Who should I tell?
http://www.boost.org/libs/test/example/unit_test_example1.cpp http://www.boost.org/libs/test/example/unit_test_example2.cpp http://www.boost.org/libs/test/example/unit_test_example3.cpp http://www.boost.org/libs/test/example/unit_test_example4.cpp http://www.boost.org/libs/test/example/unit_test_example5.cpp
Thanks for the help.
Stephen
I raised a Trac ticket about this a week or so ago - Ticket #956. The file names referenced in the documentation don't match up with the example files. e.g. unit_test_example1.cpp => unit_test_example_01.cpp. -- Regards, Rod.
Did the example, I presented, resolved issue with multiple test suites? As for docs, they are going to be updated soon. Genandiy
participants (3)
-
Gennadiy Rozental
-
Stephen Torri
-
yahooï¼ hamenga.com