boost test doesn't track validation outside auto functions
I have a test program that looks like this, in stylized form:
--------------------------
#include
I have a test program that looks like this, in stylized form: -------------------------- #include
using namespace boost::unit_test_framework;
You shouldn't need this.
void validate(X args) { if (some tests) BOOST_ERROR("message"); } BOOST_AUTO_UNIT_TEST(testfunction) { // set up arguments validate(args) } ---------------------------------- When I run this with report-level detailed, it reports that there are 0 assertions in testfunction. Furthermore, the assertions done in validate are not even added to the overall number of assertions reported for the run.
I couldn't reproduce it. And frankly it kinda hard to believe. There should be absolutely no difference where your assertion is located: directly in test function or in some other function you called from it.
I know the checks are being run, because I have seen errors from them. Also, the error messages include the name "testfunction", so it is available at run time.
Could you post complete compilable example?
It would be nice if the error reporting and logging functions got their info at run-time; apparently they are grabbing it from some pre-processor magic at the moment (I haven't examined the code in detail; that's just an inference from the behavior).
Since the tests do seem to be run, this is basically a cosmetic problem, but it would be nice to fix.
If any easy fixes occur to anyone, I'd love to know.
Boost 1.31.0 on Debian.
P.S. The module's author is listed as rogeeff@fusemail.com in the documentation, but that address doesn't work.
Yes. This address is no more free and I don't use it anymore. Use rogeeff at patmedia dot net. Gennadiy.
On Tue, 2004-06-29 at 19:29, Gennadiy Rozental wrote:
I have a test program that looks like this, in stylized form: -------------------------- #include
using namespace boost::unit_test_framework;
You shouldn't need this.
void validate(X args) { if (some tests) BOOST_ERROR("message"); } BOOST_AUTO_UNIT_TEST(testfunction) { // set up arguments validate(args) } ---------------------------------- When I run this with report-level detailed, it reports that there are 0 assertions in testfunction. Furthermore, the assertions done in validate are not even added to the overall number of assertions reported for the run.
I couldn't reproduce it. And frankly it kinda hard to believe. There should be absolutely no difference where your assertion is located: directly in test function or in some other function you called from it. I think the problem is a think-o on my part. In the pseudo-code above, BOOST_ERROR is not executed unless "some tests" is true. So if the tests are OK, BOOST_ERROR is never hit.
I think the report of 0 (boost) tests being run is therefore accurate, though confusing. Does that sound right? Is there a way to signal to boost that you are doing a test, without the error? I suppose, trivially, I could do if (some tests) BOOST_ERROR("message"); else BOOST_CHECK(true);
participants (2)
-
Gennadiy Rozental
-
Ross Boylan