To write out diagnostic text from a test, use the OutputTextStream function, which recognizes the standard C++ << operator for all built-in types. Text output produced with OutputTextStream displays to the console and is also saved in a ITieredTextBuffer within the test. You can then log the test, including the text buffer. If a test fails, you can retrieve the associated diagnostic text to determine the cause of the failure.
OutputTextStream returns a pointer to a ITieredTextBuffer object that contains the text. Objects of the class ITieredTextBuffer act like C++ ostream objects. They support << operators for all built-in types and for some basic VisualAge C++ types.
Output text is printed via ITieredTextBuffer. You can acquire the ITieredTextBuffer of the test by calling outputTextStream().
void IMyTest::test() // This method is in a subclass of ITest
{
outputTextStream() << "hello, world";
}
"Hello, world" is printed out to console when test is running. Information is marked with a level of importance. The text objects in a text buffer are ITieredText objects, so you can show a specified amount of detail when you later retrieve the text. You can also filter out information beyond a specific level of detail.
ITieredTextBuffer allows you to set the tier or indentation for the text. The tier levels are defined as follows in ITieredTextBuffer:
Most text occupies the tier kNormal. Important information that should not be missed occupies tier kGeneral or kHeadline. Detailed information that can usually be ignored occupies tier kDetail or kDebug.
void ISecondTest::test() // This method is in a subclass of ITest{
ITieredTextBuffer& out = outputTextStream();
out.pushTier(ITieredTextBuffer::kHeadline);
out << "running isecondtest\n";
out.setrelativeindent(1) << '\n';
out << "options are: [-c <timing count>] [-s <sample count>]\n";
out.setRelativeIndent(-1);
out.popTier();
}