test_suite execution (unit test framework)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

test_suite execution (unit test framework)

Alexander Eisenhuth
Hello alltogether,

it seems, that the a test_case-failure (BOOST_ERROR("")), skips only the actual
test case, but all following tests are executed. Is that possible ? ... or am I
doing something wrong?


Here my code:
[...]
boost::shared_ptr<testTestExecutor> aInstance( new testTestExecutor );

// here happens a failure
pTestSuite->add(
        BOOST_CLASS_TEST_CASE(&testTestExecutor::setUp, aInstance));

// but this is also executed
pTestSuite->add(
        BOOST_CLASS_TEST_CASE(&testTestExecutor::testConstruction, aInstance));

pTestSuite->add(
        BOOST_CLASS_TEST_CASE( &testTestExecutor::testTestExecutorMethode, aInstance));
[...]


Can I configure that behaviour ?

Regards
Alexander

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: test_suite execution (unit test framework)

Gennadiy Rozental
> Hello alltogether,
>
> it seems, that the a test_case-failure (BOOST_ERROR("")), skips only the
> actual
> test case, but all following tests are executed. Is that possible ? ... or
> am I
> doing something wrong?


Yes. Non system-fatal error (memory access violation for example) won't
cause the testing to halt. Only  the affected test case is aborted.

>
> Here my code:
> [...]
> boost::shared_ptr<testTestExecutor> aInstance( new testTestExecutor );
>
> // here happens a failure
> pTestSuite->add(
> BOOST_CLASS_TEST_CASE(&testTestExecutor::setUp, aInstance));
>
> // but this is also executed
> pTestSuite->add(
> BOOST_CLASS_TEST_CASE(&testTestExecutor::testConstruction, aInstance));
>
> pTestSuite->add(
> BOOST_CLASS_TEST_CASE( &testTestExecutor::testTestExecutorMethode,
> aInstance));
> [...]
>
>
> Can I configure that behaviour ?

One option is to use test case dependency feature. For example if you have
setup test case and you prefer failure in this test case prevent other to be
executed you could do:

test_case* setup_tc = BOOST_CLASS_TEST_CASE(&testTestExecutor::setUp,
aInstance);
test_case* const_tc =
BOOST_CLASS_TEST_CASE(&testTestExecutor::testConstruction, aInstance);

const_tc->depends_on( setup_tc );

If you have multiple Test cases that depend on it you could do it all in one
shot with extra test suite:


test_case* setup_tc = BOOST_CLASS_TEST_CASE(&testTestExecutor::setUp,
aInstance);
test_siute* ts = BOOST_TEST_SUITE("PostSetup");

ts->depends_on( depends_on );

Now add all test cases to the "PostSetup" test suite.

Gennadiy



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users