|
Boost : |
From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2005-12-15 04:46:38
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?
> Here is the list of all available macros:
>
[snip]
>
> ----------------------------------------------------
> BOOST_FIXTURE_TEST_CASE( test_name, F )
> ----------------------------------------------------
>
> Simple free function like test case. Employs struct F as a fixture.
> Use like this:
>
> struct F {
> F() { /* setup here */}
> ~F() { /* teardown here */}
>
> int i;
> };
>
> BOOST_FIXTURE_TEST_CASE( test, F )
> {
> // test body
> // i could be referenced here
> }
I haven't used Boost.Test previously, as I was missing some of the automatic
test case registration and fixtures features from CppUnit. However, as I
always use Boost in my projects I'd be happy to get rid of the CppUnit
dependency.
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?
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.
[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.
>
> BOOST_FIXTURE_TEST_SUITE( s, F )
>
> // this test case use F as a fixture
> BOOST_AUTO_TEST_CASE( test1 )
> {
> // body here
> }
>
> BOOST_AUTO_TEST_SUITE_END()
>
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)?
Also, how about having a BOOST_FIXTURE_TEST_SUITE_END macro for symmetry
(simply resolving to BOOST_AUTO_TEST_SUITE_END)?
> ----------------------------------------------------
> BOOST_GLOBAL_FIXTURE( F )
> ----------------------------------------------------
>
> Facilitate an ability to do global setup/teardown. Setup is invoked
> before any testing is started. Teardown - when all is done.
Great!
[snip rest]
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 ...
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
Sorry for the noise if this feature already exists and I've missed it.
// Johan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk