[Test] BOOST_CHECK_EXCEPTION error message still vague
In BOOST_1_59_0, I complained that the error message from BOOST_CHECK_EXCEPTION was indecipherable. In BOOST_1_60_0, things improved a lot. But it still leave you hanging. I use the function fail_msg() as the predicate argument to BOOST_CHECK_EXCEPTION. If it finds a specified substring in the exception message, it returns true. Otherwise, it returns false. Below is an error message from BOOST_CHECK_EXCEPTION when the predicate returned false: exception "std::runtime_error" raised as expected: validation on the raised exception through predicate "fail_msg" The first clause says my code raised the expected exception class. That part of the message is clear and unambiguous. The second clause, however, is a non-sequitur. It seems to only acknowledge that there was a predicate named "fail_msg" without saying whether it returned true or false. Overall, the whole message doesn't say whether BOOST_CHECK_EXCEPTION passed or failed. Since a message was output, the user can assume things did not go well, but it seems like the message could be more explicit. Merrill Cornish
Le 05/02/16 19:06, Merrill Cornish a écrit :
In BOOST_1_59_0, I complained that the error message from BOOST_CHECK_EXCEPTION was indecipherable. In BOOST_1_60_0, things improved a lot. But it still leave you hanging.
I use the function fail_msg() as the predicate argument to BOOST_CHECK_EXCEPTION. If it finds a specified substring in the exception message, it returns true. Otherwise, it returns false. Below is an error message from BOOST_CHECK_EXCEPTION when the predicate returned false:
exception "std::runtime_error" raised as expected: validation on the raised exception through predicate "fail_msg"
The first clause says my code raised the expected exception class. That part of the message is clear and unambiguous.
The second clause, however, is a non-sequitur. It seems to only acknowledge that there was a predicate named "fail_msg" without saying whether it returned true or false. Overall, the whole message doesn't say whether BOOST_CHECK_EXCEPTION passed or failed. Since a message was output, the user can assume things did not go well, but it seems like the message could be more explicit.
Merrill Cornish
Hi, If I am not mistaken, there should be an "error" in front of this line, so that the log reads: some.cpp:34: error: in "test_case_name": exception "std::runtime_error" raised as expected: validation on the raised exception through predicate "fail_msg" which means that the predicate is not passing the test (returning false, see http://www.boost.org/doc/libs/1_60_0/libs/test/doc/html/boost_test/utf_refer... ). The same message appears as either a positive or negative, depending on the log level: if you run the test with --log_level=all you may see something like: some.cpp:34: check 'exception "std::runtime_error" raised as expected: validation on the raised exception through predicate "fail_msg"' has passed I agree that the message is a bit clumsy, since I am not a native English speaker, any suggestion is welcome. Best, Raffi
Raffi,
"...validation on the raised exception through predicate "fail_msg""
which means that the predicate is not passing the test
If the message in the first line means "the predicate is not passing the test," then the first line should say, "the predicate is not passing the test." As it is, the first line only says that the predicate was named "fail_msg." The BOOST_CHECK_EXCEPTION is a little different in that it has a two part pass/fail condition: [1] was the correct exception raised or not, and [2] did the predicate returned pass or fail. Using the std::runtime_error exception and "fail_msg" predicate name from my original post as an example, there would be three possible error messages: * Assertion failed: Exception "std::runtime_error" was not raised as expected. < in this case, we do not care about the predicate > * Assertion failed: Exception "std::runtime_error" was raised as expected. The predicate, "fail_msg", failed. * Assertion passed: Exception "std::runtime_error" was raised as expected. The predicate, "fail_msg", passed. < you would need this message only if --log_level=all > Merrill
participants (2)
-
Merrill Cornish
-
Raffi Enficiaud