MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2004 Sandia Corporation and Argonne National 00005 Laboratory. Under the terms of Contract DE-AC04-94AL85000 00006 with Sandia Corporation, the U.S. Government retains certain 00007 rights in this software. 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 (lgpl.txt) along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 diachin2@llnl.gov, djmelan@sandia.gov, mbrewer@sandia.gov, 00024 pknupp@sandia.gov, tleurent@mcs.anl.gov, tmunson@mcs.anl.gov 00025 00026 ***************************************************************** */ 00027 #ifndef MESQUITE_TESTRUNNER_HPP 00028 #define MESQUITE_TESTRUNNER_HPP 00029 00030 #include <cppunit/TestListener.h> 00031 #include <cppunit/TestSuite.h> 00032 #include <string> 00033 #include <stack> 00034 #include <vector> 00035 #include <iostream> 00036 #include "Mesquite.hpp" 00037 00038 namespace MBMesquite 00039 { 00040 class Timer; 00041 00042 /*! 00043 * \brief A class the runs cppunit tests, outputs results in an organized manner. 00044 * 00045 * The test runner manages the life cycle of the added tests. 00046 * 00047 * Here is an example of use: 00048 * 00049 * \code 00050 * MBMesquite::TestRunner runner; 00051 * runner.addTest( ExampleTestCase::suite() ); 00052 * runner.run( "Darryl's Test Run" ); // Run all tests and wait 00053 * \endcode 00054 * 00055 */ 00056 class CPPUNIT_API TestRunner : protected CppUnit::TestListener 00057 { 00058 public: 00059 TestRunner(); 00060 virtual ~TestRunner(); 00061 00062 void add_test( CppUnit::Test* test ); 00063 virtual bool run( const std::string& name_of_run, std::ostream& out_stream = std::cout ); 00064 00065 protected: 00066 void delete_all_tests(); 00067 const std::string running_test_prefix(); 00068 inline void indent(); 00069 00070 // TestListener functions 00071 virtual void startSuite( CppUnit::TestSuite* suite ); 00072 virtual void startTest( CppUnit::Test* test ); 00073 virtual void addFailure( const CppUnit::TestFailure& failure ); 00074 virtual void endTest( CppUnit::Test* test ); 00075 virtual void endSuite( CppUnit::TestSuite* suite ); 00076 00077 // Timer functions 00078 inline void push_timer( Mesquite::Timer* timer ); 00079 inline MBMesquite::Timer* pop_timer(); 00080 00081 private: 00082 std::vector< CppUnit::Test* > mTests; 00083 std::stack< Mesquite::Timer* > mTimers; 00084 std::stack< int > failureCounters; 00085 std::vector< std::string > failedTestNames; 00086 std::ostream* mOut; 00087 CppUnit::TestResult* myResult; 00088 unsigned int indentLevel; 00089 unsigned int numSuccesses; 00090 unsigned int numFailures; 00091 unsigned int numExceptions; 00092 static const unsigned char INDENT_SIZE; 00093 }; 00094 } // namespace MBMesquite 00095 00096 #endif