Home > The Unit Test Framework > User's guide > Test Output > Test log > BOOST_TEST_MESSAGE
PrevNext

BOOST_TEST_MESSAGE

The macro BOOST_TEST_MESSAGE is intended to be used for the purpose of injecting an additional message into the UTF test log. These messages are not intended to indicate any error or warning conditions, but rather as information/status notifications. The macro signature is as follows:
BOOST_TEST_MESSAGE 宏用於在 UTF 測試日誌中注入額外的信息。 這些信息不是用於表明錯誤或警告情況,而是信息 / 狀態通知。宏的簽名如下:

BOOST_TEST_MESSAGE(test_message)

The test_message argument can be as simple as C string literal or any custom expression that you can produce with in a manner similar to standard iostream operation.
參數 test_message 可以是簡單的 C 字符串常量,或者是行為類似於標準流操作的自定義表達式。

[Important] Important

Messages generated by this tool do not appear in test log output with default value of the active log level threshold. For these messages to appear the active log level threshold has to be set to a value below or equal to "message".
這個工具產生的信息,在默認的活動日誌級別閾值下,並不會出現在測試日誌輸出中。 想要輸出這些信息,活動日誌級別閾值需要被設置為等於或低於 "信息"。

Example 27. BOOST_TEST_MESSAGE usage

#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>

//____________________________________________________________________________//

BOOST_AUTO_TEST_CASE( test_init )
{
    int current_time = 0; // real call is required here

    BOOST_TEST_MESSAGE( "Testing initialization :" );
    BOOST_TEST_MESSAGE( "Current time:" << current_time );
}

//____________________________________________________________________________//

BOOST_AUTO_TEST_CASE( test_update )
{
    std::string field_name = "Volume";
    int         value      = 100;

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

//____________________________________________________________________________//
Source code | Show output
> example --log_level=message
Running 2 test cases...
Testing initialization :
Current time:0
Testing update :
Update Volume with 100

*** No errors detected


PrevUpHomeNext