The log feature allow logging trace in addition to assertion made during testing. This can be used to provided more context to the assertion being made and their failure.

Here is a simple example of usage:

   1 static void testLogDemo()
   2 {
   3    for ( int index =0; index < 5; ++index )
   4    {
   5       CppUT::log( "index is " + CppTL::toString(index) );
   6       CPPUT_CHECK_EXPR( index % 2 == 0 );
   7    }
   8 }

Running the test print all the checking assertion failures, as well as the text logged by call to CppUt::log():

Testing /All tests/testLogDemo : FAIL
Failure report:
-> /All tests/testLogDemo : assertion
Log:
index is 0

Log:
index is 1

examples\log_demo\main.cpp(15) : [failure type: assertion]
Messages:
expression did not evaluate to true.
- index % 2 == 0

Log:
index is 2

Log:
index is 3

examples\log_demo\main.cpp(15) : [failure type: assertion]
Messages:
expression did not evaluate to true.
- index % 2 == 0

Log:
index is 4

0/1 tests passed, 1 tests failed.

CppUnit2/Log (last edited 2008-02-26 06:29:57 by localhost)

SourceForge.net Logo