My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
libpolys
tests
cxxtest
TestRunner.h
Go to the documentation of this file.
1
#ifndef __cxxtest_TestRunner_h__
2
#define __cxxtest_TestRunner_h__
3
4
//
5
// TestRunner is the class that runs all the tests.
6
// To use it, create an object that implements the TestListener
7
// interface and call TestRunner::runAllTests( myListener );
8
//
9
10
#include <
cxxtest/TestListener.h
>
11
#include <
cxxtest/RealDescriptions.h
>
12
#include <
cxxtest/TestSuite.h
>
13
#include <
cxxtest/TestTracker.h
>
14
15
namespace
CxxTest
16
{
17
class
TestRunner
18
{
19
public
:
20
static
void
runAllTests
(
TestListener
&listener )
21
{
22
tracker
().
setListener
( &listener );
23
_TS_TRY
{
TestRunner
().
runWorld
(); }
24
_TS_LAST_CATCH
( {
tracker
().
failedTest
( __FILE__, __LINE__,
"Exception thrown from world"
); } );
25
tracker
().
setListener
( 0 );
26
}
27
28
static
void
runAllTests
(
TestListener
*listener )
29
{
30
if
( listener ) {
31
listener->
warning
( __FILE__, __LINE__,
"Deprecated; Use runAllTests( TestListener & )"
);
32
runAllTests
( *listener );
33
}
34
}
35
36
private
:
37
void
runWorld
()
38
{
39
RealWorldDescription
wd;
40
WorldGuard
sg;
41
42
tracker
().
enterWorld
( wd );
43
if
( wd.
setUp
() ) {
44
for
(
SuiteDescription
*sd = wd.
firstSuite
(); sd; sd = sd->
next
() )
45
if
( sd->active() )
46
runSuite
( *sd );
47
48
wd.
tearDown
();
49
}
50
tracker
().
leaveWorld
( wd );
51
}
52
53
void
runSuite
(
SuiteDescription
&sd )
54
{
55
StateGuard
sg;
56
57
tracker
().
enterSuite
( sd );
58
if
( sd.
setUp
() ) {
59
for
(
TestDescription
*td = sd.
firstTest
(); td; td = td->
next
() )
60
if
( td->active() )
61
runTest
( *td );
62
63
sd.
tearDown
();
64
}
65
tracker
().
leaveSuite
( sd );
66
}
67
68
void
runTest
(
TestDescription
&td )
69
{
70
StateGuard
sg;
71
72
tracker
().
enterTest
( td );
73
if
( td.
setUp
() ) {
74
td.
run
();
75
td.
tearDown
();
76
}
77
tracker
().
leaveTest
( td );
78
}
79
80
class
StateGuard
81
{
82
#ifdef _CXXTEST_HAVE_EH
83
bool
_abortTestOnFail;
84
#endif
// _CXXTEST_HAVE_EH
85
unsigned
_maxDumpSize
;
86
87
public
:
88
StateGuard
()
89
{
90
#ifdef _CXXTEST_HAVE_EH
91
_abortTestOnFail =
abortTestOnFail
();
92
#endif
// _CXXTEST_HAVE_EH
93
_maxDumpSize
=
maxDumpSize
();
94
}
95
96
~StateGuard
()
97
{
98
#ifdef _CXXTEST_HAVE_EH
99
setAbortTestOnFail
( _abortTestOnFail );
100
#endif
// _CXXTEST_HAVE_EH
101
setMaxDumpSize
(
_maxDumpSize
);
102
}
103
};
104
105
class
WorldGuard
:
public
StateGuard
106
{
107
public
:
108
WorldGuard
() :
StateGuard
()
109
{
110
#ifdef _CXXTEST_HAVE_EH
111
setAbortTestOnFail
(
CXXTEST_DEFAULT_ABORT
);
112
#endif
// _CXXTEST_HAVE_EH
113
setMaxDumpSize
(
CXXTEST_MAX_DUMP_SIZE
);
114
}
115
};
116
};
117
118
//
119
// For --no-static-init
120
//
121
void
initialize
();
122
};
123
124
125
#endif
// __cxxtest_TestRunner_h__
CXXTEST_MAX_DUMP_SIZE
#define CXXTEST_MAX_DUMP_SIZE
Definition
Flags.h:52
CXXTEST_DEFAULT_ABORT
#define CXXTEST_DEFAULT_ABORT
Definition
Flags.h:60
RealDescriptions.h
TestListener.h
TestSuite.h
_TS_TRY
#define _TS_TRY
Definition
TestSuite.h:209
_TS_LAST_CATCH
#define _TS_LAST_CATCH(b)
Definition
TestSuite.h:215
TestTracker.h
CxxTest::Link::setUp
virtual bool setUp()=0
CxxTest::Link::tearDown
virtual bool tearDown()=0
CxxTest::RealWorldDescription
Definition
RealDescriptions.h:202
CxxTest::RealWorldDescription::setUp
bool setUp()
Definition
RealDescriptions.cpp:262
CxxTest::RealWorldDescription::firstSuite
SuiteDescription * firstSuite()
Definition
RealDescriptions.cpp:226
CxxTest::RealWorldDescription::tearDown
bool tearDown()
Definition
RealDescriptions.cpp:278
CxxTest::SuiteDescription
Definition
Descriptions.h:32
CxxTest::SuiteDescription::firstTest
virtual TestDescription * firstTest()=0
CxxTest::SuiteDescription::next
virtual SuiteDescription * next()=0
CxxTest::TestDescription
Definition
Descriptions.h:16
CxxTest::TestDescription::next
virtual const TestDescription * next() const =0
CxxTest::TestDescription::run
virtual void run()=0
CxxTest::TestListener
Definition
TestListener.h:18
CxxTest::TestListener::warning
virtual void warning(const char *, unsigned, const char *)
Definition
TestListener.h:28
CxxTest::TestRunner::StateGuard
Definition
TestRunner.h:81
CxxTest::TestRunner::StateGuard::StateGuard
StateGuard()
Definition
TestRunner.h:88
CxxTest::TestRunner::StateGuard::_maxDumpSize
unsigned _maxDumpSize
Definition
TestRunner.h:85
CxxTest::TestRunner::StateGuard::~StateGuard
~StateGuard()
Definition
TestRunner.h:96
CxxTest::TestRunner::WorldGuard
Definition
TestRunner.h:106
CxxTest::TestRunner::WorldGuard::WorldGuard
WorldGuard()
Definition
TestRunner.h:108
CxxTest::TestRunner
Definition
TestRunner.h:18
CxxTest::TestRunner::runWorld
void runWorld()
Definition
TestRunner.h:37
CxxTest::TestRunner::runAllTests
static void runAllTests(TestListener *listener)
Definition
TestRunner.h:28
CxxTest::TestRunner::runSuite
void runSuite(SuiteDescription &sd)
Definition
TestRunner.h:53
CxxTest::TestRunner::runAllTests
static void runAllTests(TestListener &listener)
Definition
TestRunner.h:20
CxxTest::TestRunner::runTest
void runTest(TestDescription &td)
Definition
TestRunner.h:68
CxxTest::TestTracker::leaveWorld
void leaveWorld(const WorldDescription &wd)
Definition
TestTracker.cpp:109
CxxTest::TestTracker::enterTest
void enterTest(const TestDescription &td)
Definition
TestTracker.cpp:90
CxxTest::TestTracker::enterWorld
void enterWorld(const WorldDescription &wd)
Definition
TestTracker.cpp:76
CxxTest::TestTracker::failedTest
void failedTest(const char *file, unsigned line, const char *expression)
Definition
TestTracker.cpp:126
CxxTest::TestTracker::setListener
void setListener(TestListener *l)
Definition
TestTracker.cpp:71
CxxTest::TestTracker::enterSuite
void enterSuite(const SuiteDescription &sd)
Definition
TestTracker.cpp:83
CxxTest::TestTracker::leaveSuite
void leaveSuite(const SuiteDescription &sd)
Definition
TestTracker.cpp:103
CxxTest::TestTracker::leaveTest
void leaveTest(const TestDescription &td)
Definition
TestTracker.cpp:97
CxxTest
Definition
Descriptions.cpp:7
CxxTest::abortTestOnFail
bool abortTestOnFail()
Definition
TestSuite.cpp:20
CxxTest::maxDumpSize
unsigned maxDumpSize()
Definition
TestSuite.cpp:43
CxxTest::setMaxDumpSize
void setMaxDumpSize(unsigned value)
Definition
TestSuite.cpp:48
CxxTest::tracker
TestTracker & tracker()
Definition
TestTracker.h:111
CxxTest::initialize
void initialize()
CxxTest::setAbortTestOnFail
void setAbortTestOnFail(bool value)
Definition
TestSuite.cpp:25
Generated on
for My Project by
doxygen 1.17.0
for
Singular