Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] boost::test equivalent of CppUnit's "protectors" ?
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2009-05-08 04:19:23

Tim Day <timday <at>> writes:

> I've used both CppUnit and boost::test for C++ unittesting. Generally I
> prefer boost::test, mainly because the auto-test macros minimise the
> effort to setup tests. But there's one thing I really miss from CppUnit:
> the ability to register your own custom "protectors", instances of which
> automatically wrap all the run tests. (Technically, you install a test
> "listener", and that can wrap each test run in a protector scope.
> Multiple listeners and nested protectors are possible).

You can register test observers using framework::register_observer.

See the header test_observer.hpp and framework.hpp for interface definition.
> I've found these invaluable in the past for monitoring unittests for
> unexpected side effects (e.g checking code hasn't changed the
> floating-point unit state flags, or messed with other global state). I
> can't see any equivalent in the boost::test documentation, although

These are more on advanced usage side and are not coverred in current docs.

> BOOST_FIXTURE_TEST_CASE maybe comes closest. (However, whereas a
> CppUnit protector can return a bool to indicate pass/fail, it's less
> clear to me how a fixture destructor should indicate failure).

What and where you want to indicate? How framework has to respond to this


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at