BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES and BOOST_FAIL

Is there a way to flag that a Boost.Test auto test case is expected to utterly fail per BOOST_FAIL? BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES does not seem to handle this use case correctly. Running Boost.Test 1.42's example 22 [1] returns EXIT_SUCCESS to the operating system. When I replace BOOST_CHECK with BOOST_FAIL within the sample's my_test1 test case the binary returns EXIT_FAILURE to the OS. I have attached the modified version. I see the same behavior for BOOST_REQUIRE_MESSAGE(false,...). The question arises because I'm using BOOST_FAIL within an error handling callback that I provide to a library. When the library issues the callback, all hope is lost and I need to unwind the test case to continue sanely. Thanks, Rhys [1] http://www.boost.org/doc/libs/1_42_0/libs/test/doc/html/utf/user-guide/test-...

Rhys Ulerich wrote:
Is there a way to flag that a Boost.Test auto test case is expected to utterly fail per BOOST_FAIL? BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES does not seem to handle this use case correctly.
Hmm. Strange. I thought I've replied to this post. The answer is no. You can only "expect" non-fatal errors
The question arises because I'm using BOOST_FAIL within an error handling callback that I provide to a library. When the library issues the callback, all hope is lost and I need to unwind the test case to continue sanely.
There is no reason to use fatal error here. Since you can register any callback you want the easiest solution is to bind result_status variable to the callback and set it to false if processing failed. Once outside of the library call if can check the flag value and continue or not depending on it's value. You can also "expect" that this value is false, but the further testing is still aborted. Gennadiy
participants (2)
-
Gennadiy Rozental
-
Rhys Ulerich