Boost Users :
Subject: Re: [Boost-users] [test] boost::test equivalent of CppUnit's "protectors" ?
From: Tim Day (timday_at_[hidden])
Date: 2009-05-11 06:50:53
On Fri, 2009-05-08 at 08:19 +0000, Gennadiy Rozental wrote:
> Tim Day <timday <at> bottlenose.demon.co.uk> writes:
> > 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.
> You can register test observers using framework::register_observer.
> See the header test_observer.hpp and framework.hpp for interface
> definition. These are more on advanced usage side and are not
> coverred in current docs.
Thanks for the pointer; those look exactly like what I was looking for.
> > 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
I was just concerned that if I went down the route of trying to indicate
test(-suite) failure from BOOST_FIXTURE_TEST_CASE's destructor, pretty
much the only option would seem to be be to throw (not a nice thing to
do in a destructor) (hmmm... actually it occurs to me I have no idea how
things like BOOST_CHECK indicate to the framework that a test has
failed; it clearly isn't by throwing as, unlike BOOST_REQUIRE, execution
of the test continues. I really should look at the source more
closely). But failing a test within a test_observer::test_finish() call
seems like it ought to be a cleaner place to do it.
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