1 | #ifndef CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H |
---|
2 | #define CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H |
---|
3 | |
---|
4 | |
---|
5 | #include <cppunit/Portability.h> |
---|
6 | #include <string> |
---|
7 | #include <cppunit/TestRunner.h> |
---|
8 | |
---|
9 | CPPUNIT_NS_BEGIN |
---|
10 | |
---|
11 | |
---|
12 | class Outputter; |
---|
13 | class Test; |
---|
14 | class TestSuite; |
---|
15 | class TextOutputter; |
---|
16 | class TestResult; |
---|
17 | class TestResultCollector; |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | /*! |
---|
22 | * \brief A text mode test runner. |
---|
23 | * \ingroup WritingTestResult |
---|
24 | * \ingroup ExecutingTest |
---|
25 | * |
---|
26 | * The test runner manage the life cycle of the added tests. |
---|
27 | * |
---|
28 | * The test runner can run only one of the added tests or all the tests. |
---|
29 | * |
---|
30 | * TestRunner prints out a trace as the tests are executed followed by a |
---|
31 | * summary at the end. The trace and summary print are optional. |
---|
32 | * |
---|
33 | * Here is an example of use: |
---|
34 | * |
---|
35 | * \code |
---|
36 | * CppUnit::TextTestRunner runner; |
---|
37 | * runner.addTest( ExampleTestCase::suite() ); |
---|
38 | * runner.run( "", true ); // Run all tests and wait |
---|
39 | * \endcode |
---|
40 | * |
---|
41 | * The trace is printed using a TextTestProgressListener. The summary is printed |
---|
42 | * using a TextOutputter. |
---|
43 | * |
---|
44 | * You can specify an alternate Outputter at construction |
---|
45 | * or later with setOutputter(). |
---|
46 | * |
---|
47 | * After construction, you can register additional TestListener to eventManager(), |
---|
48 | * for a custom progress trace, for example. |
---|
49 | * |
---|
50 | * \code |
---|
51 | * CppUnit::TextTestRunner runner; |
---|
52 | * runner.addTest( ExampleTestCase::suite() ); |
---|
53 | * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( |
---|
54 | * &runner.result(), |
---|
55 | * std::cerr ) ); |
---|
56 | * MyCustomProgressTestListener progress; |
---|
57 | * runner.eventManager().addListener( &progress ); |
---|
58 | * runner.run( "", true ); // Run all tests and wait |
---|
59 | * \endcode |
---|
60 | * |
---|
61 | * \see CompilerOutputter, XmlOutputter, TextOutputter. |
---|
62 | */ |
---|
63 | class CPPUNIT_API TextTestRunner : public CPPUNIT_NS::TestRunner |
---|
64 | { |
---|
65 | public: |
---|
66 | TextTestRunner( Outputter *outputter =NULL ); |
---|
67 | |
---|
68 | virtual ~TextTestRunner(); |
---|
69 | |
---|
70 | bool run( std::string testPath ="", |
---|
71 | bool doWait = false, |
---|
72 | bool doPrintResult = true, |
---|
73 | bool doPrintProgress = true ); |
---|
74 | |
---|
75 | void setOutputter( Outputter *outputter ); |
---|
76 | |
---|
77 | TestResultCollector &result() const; |
---|
78 | |
---|
79 | TestResult &eventManager() const; |
---|
80 | |
---|
81 | public: // overridden from TestRunner (to avoid hidden virtual function warning) |
---|
82 | virtual void run( TestResult &controller, |
---|
83 | const std::string &testPath = "" ); |
---|
84 | |
---|
85 | protected: |
---|
86 | virtual void wait( bool doWait ); |
---|
87 | virtual void printResult( bool doPrintResult ); |
---|
88 | |
---|
89 | TestResultCollector *m_result; |
---|
90 | TestResult *m_eventManager; |
---|
91 | Outputter *m_outputter; |
---|
92 | }; |
---|
93 | |
---|
94 | |
---|
95 | CPPUNIT_NS_END |
---|
96 | |
---|
97 | #endif // CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H |
---|