Boost logo

Boost :

From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2005-12-15 16:07:37

"Johan Nilsson" <r.johan.nilsson_at_[hidden]> wrote in message
> Gennadiy Rozental wrote:
>> Hi,
>> This message should serve as a temporary source of information
>> regarding self registration faculties of Boost.Test. I will include the
>> complete docs in next update.
> 1.34?

I plan at least 3 updates before 1.34. Depends though how soon it will occur

> One of my pet peeves about CppUnit (and most of the xUnit frameworks) is
> that there's usually no controllable way of indicating a fixture setup
> failure. I'm running hardware dependent tests in a couple of my projects
> (e.g. serial port communications). I need a _supported_ way of indicating
> a setup error, leading to no further tests being executed in the same
> suite. Is this possible using Boost.Test?

If I gather correctly you need one per suite fixture. It's last kind of
fixture not yet supported and It's in my to do list for update 3. Once it's
done you could just throw an exception to indicate init failure

> My main point is that the framework should be prepared for an exception to
> be thrown from the fixture setup (in this case, during F's ctor), and
> report it as an setup failure (including the exceptions' "what()"
> information). And, for the BOOST_FIXTURE_TEST_SUITE, don't run any tests
> within the suite when setup fails.

BOOST_FIXTURE_TEST_SUITE doing different job - The fixture is per test case.

> [snip]
>> ----------------------------------------------------
>> BOOST_FIXTURE_TEST_SUITE( suite_name, F )
>> ----------------------------------------------------
>> Similar to the BOOST_AUTO_TEST_SUITE, but force all the test cases
>> within this test suite to use struct F as a fixture.
>> // this test case use F as a fixture
>> {
>> // body here
>> }
> Do all the test cases within the BOOST_FIXTURE_TEST_SUITE and
> BOOST_AUTO_TEST_SUITE_END macros share the same instance of F (I'd
> personally prefer that)?

No. I think that would defeat the purpose. You could always mimic what you
want with plain Static instance:

struct F{} f;

 TEST_CASE( t1 )
    f.i ...

 TEST_CASE( t2 )
    f.i ...

> Also, how about having a BOOST_FIXTURE_TEST_SUITE_END macro for symmetry
> (simply resolving to BOOST_AUTO_TEST_SUITE_END)?

I don't see a need for this. BOOST_AUTO_TEST_SUITE_END ends any test suite.

> Another question, is there any possibility to implement hierarchical auto
> test suite registrations, e.g.:
> <i/o test suite> - "io"
> <ip test suite> - "ip"
> <http test suite> - "http"
> <file test suite> - "file"
> ... etc ...

Yes. BOOST_AUTO_TEST_SUITE could be put inside one another. Check examples
in libs/example directory.

> With reference to the test runner, it would be great to be able to specify
> e.g.:
> <runner> --run-tests "io" run all tests from
> "io","ip","http","file" test suites
> <runner> --run_tests "io/ip" run all tests from "ip","http" test suites

"Run test by name" is scheduled for update 3.


Boost list run by bdawes at, gregod at, cpdaniel at, john at