> The Unit Test Framework > User's guide > Test Output > Test log > |
The test log is produced during the test execution. All entries in the test log are assigned a particular log level. Only the entries with level that exceeds the active log level threshold actually appear in the test log output. Log levels are arranged by the "importance" of the log entries. Here is the list of all levels in order of increasing "importance":
Success information messages
This category includes messages that provide information on successfully passed assertions
Test tree traversal notifications
This category includes messages that are produced by the UTF core and indicate which test suites/cases are currently being executed or skipped
General information messages
This category includes general information massages produced in most cases by a test module author using the
macro BOOST_TEST_MESSAGE
.
Warning messages
This category includes messages produced by failed warning level assertions.
Non fatal error messages
This category includes messages produced by failed check level assertions
Uncaught C++ exceptions notifications
This category includes messages that are produced by the UTF and provide detailed information on the C++ exceptions uncaught by the test case body.
Non-fatal system error
This category includes messages that are produced by the UTF itself and provides information about caught non-fatal system error. For example it includes messages produced in the case of test case timeout or if floating point values calculation errors are caught.
Fatal system error
This category includes messages produced by failed require level assertions and by the UTF itself in case of abnormal test case termination.
Note | |
---|---|
The active log level works namely as threshold, not as selector. For the given active log level threshold, all test log entries with "importance" higher than threshold are enabled and all test log entries with "importance" below threshold are disabled. |
In addition to the levels described above the test log defines two special log levels. The current log level can be set to:
All messages
If active log level threshold is set to this value, all test log entries appear in the output. In practice this is equivalent to setting the active log level threshold to "success information messages"
Nothing
If the active log level threshold is set to this value, none of test log entries appear in the output. This log level is used to execute a "silent" test that doesn't produce any test log and only generates a result code indicating whether test failed or passed.
By default the active log level threshold is set to "non fatal error messages" and the test log output is generated in the human readable format. The active log level threshold and the output format can be configured at runtime during a test module invocation and at compile time from within a test module using the test log public interfaces. For example, for automated test module output processing it might be more convenient to use the XML based format.
In most cases The UTF can't provide an exact location, where system error occurs or uncaught C++ exception
is thrown from. To be able to pinpoint it as close as possible the UTF keeps track of checkpoints - the
location a test module passed through. A test case entrance and exit points, a test tool invocation point the
UTF tracks automatically. Any other checkpoints should be entered by you manually. The test log provides two
macros for this purpose: BOOST_TEST_CHECKPOINT
- to specify a "named" checkpoint
and BOOST_TEST_PASSPOINT
- to specify an "unnamed" checkpoint.
Most of the testing tools print values of their arguments to the output
stream in some form of log statement. If arguments type does not support operator<<(std::ostream&,
ArgumentType const&)
interface you will get a compilation error. You can either implement above
interface or prohibit the testing tools from logging argument values for
specified type. To do so use following statement on file level before first test case that includes statement
failing to compile:
BOOST_TEST_DONT_PRINT_LOG_VALUE(ArgumentType)
Example 26. BOOST_TEST_DONT_PRINT_LOG_VALUE usage
Try to comment out BOOST_TEST_DONT_PRINT_LOG_VALUE statement and you end up with compile time error.
#define BOOST_TEST_MODULE example #include <boost/test/included/unit_test.hpp> #include <utility> //____________________________________________________________________________// typedef std::pair<int,float> pair_type; BOOST_TEST_DONT_PRINT_LOG_VALUE( pair_type ); BOOST_AUTO_TEST_CASE( test_list ) { pair_type p1( 2, 5.5 ); pair_type p2( 2, 5.501 ); BOOST_CHECK_EQUAL( p1, p2 ); } //____________________________________________________________________________//
Source code |
| | Show output |
Running 1 test case... test.cpp(16): error in "test_list": check p1 == p2 failed [ != ] *** 1 failure detected in test suite "example"
The active log level threshold can be configured at runtime using the parameter log_level. The test log output format can be selected using either parameter log_format or the parameter output_format.