I have a question regarding the output of the following minimal example that uses Boost test.
#define BOOST_TEST_MODULE ExampleTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
using boost::unit_test::test_suite;
using boost::unit_test::framework::master_test_suite;
#include <boost/test/data/test_case.hpp>
namespace bdata = boost::unit_test::data;
BOOST_DATA_TEST_CASE(ExampleTest, bdata::xrange(2), testDatum) {
int exp = testDatum == 0 ? 0 : 1;
BOOST_CHECK_EQUAL(testDatum, exp);
}
If I run this test with ./boost_testing --log_level=all
, I get the following output:
Running 2 test cases...
Entering test module "ExampleTestSuite"
boost_testing.cpp(11): Entering test suite "ExampleTest"
boost_testing.cpp(11): Entering test case "_0"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 0;
boost_testing.cpp(11): Leaving test case "_0"
boost_testing.cpp(11): Entering test case "_1"
boost_testing.cpp(15): info: check testDatum == exp has passed
Assertion occurred in a following context:
testDatum = 1;
boost_testing.cpp(11): Leaving test case "_1"
boost_testing.cpp(11): Leaving test suite "ExampleTest"
Leaving test module "ExampleTestSuite"
*** No errors detected
What is the meaning of the output line Assertion occurred in a following context: testDatum = 0;
? Does it indicate an issue with the way that I have set up the data-driven test case or can I safely ignore it?
I agree the message is confusing: this is in fact the description of the assertion context for the test BOOST_CHECK_EQUAL(testDatum, exp)
, and in fact this is not describing an error, but the context attached to the check. If you change --log_level=all
to something else, or user another output format, this should go away.
Feel free to raise an issue on Boost.Test project