#include <CompilerOutputter.h>
Inheritance diagram for CompilerOutputter:
List of all members.
Printing the test results in a compiler compatible format (assertion location has the same format as compiler error), allow you to use your IDE to jump to the assertion failure. Location format can be customized (see setLocationFormat() ).
For example, when running the test in a post-build with VC++, if an assertion fails, you can jump to the assertion by pressing F4 (jump to next error).
Heres is an example of usage (from examples/cppunittest/CppUnitTestMain.cpp):
int main( int argc, char* argv[] ) { // if command line contains "-selftest" then this is the post build check // => the output must be in the compiler error format. bool selfTest = (argc > 1) && (std::string("-selftest") == argv[1]); CppUnit::TextUi::TestRunner runner; runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner if ( selfTest ) { // Change the default outputter to a compiler error format outputter // The test runner owns the new outputter. runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), std::cerr ) ); } // Run the test and don't wait a key if post build check. bool wasSuccessful = runner.run( "", !selfTest ); // Return error code 1 if the one of test failed. return wasSuccessful ? 0 : 1; }
CPPUNIT_COMPILER_LOCATION_FORMAT
Constructs a CompilerOutputter object.
CPPUNIT_COMPILER_LOCATION_FORMAT
which is defined in the configuration file. See setLocationFormat() for detail.
[virtual]
Destructor.
[private]
Prevents the use of the copy constructor.
[static]
Creates an instance of an outputter that matches your current compiler.
[private, virtual]
[private]
Prevents the use of the copy operator.
[virtual]
[virtual]
[virtual]
[virtual]
[virtual]
[virtual]
[virtual]
[virtual]
[virtual]
[private, virtual]
Sets the error location format.
Indicates the format used to report location of failed assertion. This format should match the one used by your compiler.
The location format is a string in which the occurence of the following character sequence are replaced:
Some examples:
Thoses are the two compilers currently supported (gcc format is used if VC++ is not detected). If you want your compiler to be automatically supported by CppUnit, send a mail to the mailing list (preferred), or submit a feature request that indicates how to detect your compiler with the preprocessor (#ifdef...) and your compiler location format.
[virtual]
Implements Outputter.
[private]
[private]