CppUnit project page FAQ CppUnit home page

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CppUnit::CompilerOutputter Class Reference
[Writing test result]

Outputs a TestResultCollector in a compiler compatible format. More...

#include <CompilerOutputter.h>

Inheritance diagram for CppUnit::CompilerOutputter:

CppUnit::Outputter List of all members.

Public Methods

 CompilerOutputter (TestResultCollector *result, std::ostream &stream)
virtual ~CompilerOutputter ()
 Destructor. More...

void write ()
virtual void printSucess ()
virtual void printFailureReport ()
virtual void printFailuresList ()
virtual void printStatistics ()
virtual void printFailureDetail (TestFailure *failure)
virtual void printFailureLocation (SourceLine sourceLine)
virtual void printFailureType (TestFailure *failure)
virtual void printFailedTestName (TestFailure *failure)
virtual void printFailureMessage (TestFailure *failure)
virtual void printNotEqualMessage (Exception *thrownException)
virtual void printDefaultMessage (Exception *thrownException)
virtual std::string wrap (std::string message)

Static Public Methods

CompilerOutputter * defaultOutputter (TestResultCollector *result, std::ostream &stream)

Private Types

typedef std::vector< std::string > Lines

Private Methods

 CompilerOutputter (const CompilerOutputter &copy)
 Prevents the use of the copy constructor. More...

void operator= (const CompilerOutputter &copy)
 Prevents the use of the copy operator. More...


Static Private Methods

Lines splitMessageIntoLines (std::string message)

Private Attributes

TestResultCollectorm_result
std::ostream & m_stream

Detailed Description

Outputs a TestResultCollector in a compiler compatible format.

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.

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).

You should use defaultOutputter() to create an instance.

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( CppUnit::CompilerOutputter::defaultOutputter( 
                                                        &runner.result(),
                                                         std::cerr ) );
   }
 
  // Run the test and don't wait a key if post build check.
   bool wasSucessful = runner.run( "", !selfTest );
 
   // Return error code 1 if the one of test failed.
   return wasSucessful ? 0 : 1;
 }


Member Typedef Documentation

typedef std::vector<std::string> CppUnit::CompilerOutputter::Lines [private]
 


Constructor & Destructor Documentation

CppUnit::CompilerOutputter::CompilerOutputter TestResultCollector   result,
std::ostream &    stream
 

Constructs a CompilerOutputter object.

CppUnit::CompilerOutputter::~CompilerOutputter   [virtual]
 

Destructor.

CppUnit::CompilerOutputter::CompilerOutputter const CompilerOutputter &    copy [private]
 

Prevents the use of the copy constructor.


Member Function Documentation

CompilerOutputter * CppUnit::CompilerOutputter::defaultOutputter TestResultCollector   result,
std::ostream &    stream
[static]
 

Creates an instance of an outputter that matches your current compiler.

void CppUnit::CompilerOutputter::operator= const CompilerOutputter &    copy [private]
 

Prevents the use of the copy operator.

void CppUnit::CompilerOutputter::printDefaultMessage Exception   thrownException [virtual]
 

void CppUnit::CompilerOutputter::printFailedTestName TestFailure   failure [virtual]
 

void CppUnit::CompilerOutputter::printFailureDetail TestFailure   failure [virtual]
 

void CppUnit::CompilerOutputter::printFailureLocation SourceLine    sourceLine [virtual]
 

void CppUnit::CompilerOutputter::printFailureMessage TestFailure   failure [virtual]
 

void CppUnit::CompilerOutputter::printFailureReport   [virtual]
 

void CppUnit::CompilerOutputter::printFailuresList   [virtual]
 

void CppUnit::CompilerOutputter::printFailureType TestFailure   failure [virtual]
 

void CppUnit::CompilerOutputter::printNotEqualMessage Exception   thrownException [virtual]
 

void CppUnit::CompilerOutputter::printStatistics   [virtual]
 

void CppUnit::CompilerOutputter::printSucess   [virtual]
 

CompilerOutputter::Lines CppUnit::CompilerOutputter::splitMessageIntoLines std::string    message [static, private]
 

std::string CppUnit::CompilerOutputter::wrap std::string    message [virtual]
 

void CppUnit::CompilerOutputter::write   [virtual]
 

Implements CppUnit::Outputter.


Member Data Documentation

TestResultCollector* CppUnit::CompilerOutputter::m_result [private]
 

std::ostream& CppUnit::CompilerOutputter::m_stream [private]
 


The documentation for this class was generated from the following files:
SourceForge Logo hosts this site. Send comments to:
CppUnit Developers