summaryrefslogtreecommitdiff
path: root/include/cppunit/CompilerOutputter.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/cppunit/CompilerOutputter.h')
-rw-r--r--include/cppunit/CompilerOutputter.h41
1 files changed, 40 insertions, 1 deletions
diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h
index 73176ff..0075972 100644
--- a/include/cppunit/CompilerOutputter.h
+++ b/include/cppunit/CompilerOutputter.h
@@ -16,7 +16,44 @@ class TestFailure;
class TestResultCollector;
/*!
- * \brief Outputs test results in a compiler compatible format.
+ * \brief Outputs a TestResultCollector in a compiler compatible format.
+ * \ingroup WritingTestResult
+ *
+ * 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):
+ * \code
+ * 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;
+ * }
+ * \endcode
*/
class CPPUNIT_API CompilerOutputter : public Outputter
{
@@ -29,6 +66,8 @@ public:
/// Destructor.
virtual ~CompilerOutputter();
+ /*! Creates an instance of an outputter that matches your current compiler.
+ */
static CompilerOutputter *defaultOutputter( TestResultCollector *result,
std::ostream &stream );