Opened 6 years ago

Closed 5 years ago

#12631 closed Bugs (fixed)

BOOST_TEST_MESSAGE generates incorrect output when used in BOOST_DATA_TEST_CASE

Reported by: Philip Miller <philip.miller@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.65.0 Component: test
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

When I use BOOST_TEST_MESSAGE in a BOOST_DATA_TEST_CASE, I get the following misleading/incorrect output:

Entering test case "test_update"
Testing update :
Failure occurred in a following context:
    filename = util/test_image2.jpg;
Update Volume with 100
Failure occurred in a following context:
    filename = util/test_image2.jpg;
Test case TestReadImageComment/test_update did not check any assertions

The context is the the boost data test case arguments even though there are no test errors. I tried debugging the code, but how to fix this is not obvious to me.

Here is the modified test from the BOOST_TEST_MESSAGE documentation:

#if 0
BOOST_AUTO_TEST_CASE(test_update) //, *utf::disabled())
#else
std::string filenames[] = { "util/test_image2.jpg" };
BOOST_DATA_TEST_CASE(test_update,
                     btd::make(filenames),
                     filename)
#endif
{
    std::string field_name = "Volume";
    int         value = 100;

    BOOST_TEST_MESSAGE("Testing update :");
    BOOST_TEST_MESSAGE("Update " << field_name << " with " << value);
}

Change History (6)

comment:1 by Raffi Enficiaud, 6 years ago

Owner: changed from Gennadiy Rozental to Raffi Enficiaud

comment:2 by Raffi Enficiaud, 6 years ago

Would something like

Running 1 test case...
Entering test module "message in dataset"
/Users/raffi/Personnel/boost_github/libs/test/test/framework-ts/message-in-datatestcase-test.cpp:17: Entering test suite "test_update"
/Users/raffi/Personnel/boost_github/libs/test/test/framework-ts/message-in-datatestcase-test.cpp:17: Entering test case "_0"
Testing update :
Message generated in the following context:
    sample = util/test_image2.jpg; 
Update Volume with 100
Message generated in the following context:
    sample = util/test_image2.jpg; 
Test case test_update/_0 did not check any assertions
/Users/raffi/Personnel/boost_github/libs/test/test/framework-ts/message-in-datatestcase-test.cpp:17: Leaving test case "_0"; testing time: 111us
/Users/raffi/Personnel/boost_github/libs/test/test/framework-ts/message-in-datatestcase-test.cpp:17: Leaving test suite "test_update"; testing time: 163us
Leaving test module "message in dataset"; testing time: 197us

*** No errors detected
Program ended with exit code: 0

do instead? Unfortunately it will be hard to discard the second printing. Discarding any printing of context might be not desired in some circumstances as well.

comment:3 by Raffi Enficiaud, 6 years ago

Status: newassigned
Version: Boost 1.61.0Boost 1.65.0

comment:4 by anonymous, 6 years ago

Yes, I think that will do just fine. You have eliminated the clause "Failure occurred", which was the reason I wrote the original ticket.

comment:5 by Raffi Enficiaud, 5 years ago

Milestone: To Be DeterminedBoost 1.65.0
Version: Boost 1.65.0Boost 1.61.0

comment:6 by Raffi Enficiaud, 5 years ago

Resolution: fixed
Status: assignedclosed

In master, rev 3ddb0e0d29e8ebfe4ba20921a3d366f7b5b837b2

Note: See TracTickets for help on using tickets.