Boost logo

Boost Users :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2007-05-23 00:17:07


"Stephen Torri" <storri_at_[hidden]> wrote in message
news:1179889451.3672.14.camel_at_localhost.localdomain...
>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 <boost/test/unit_test.hpp>

//____________________________________________________________________________//

// 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net