-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextRunner.h
More file actions
84 lines (65 loc) · 2.18 KB
/
TextRunner.h
File metadata and controls
84 lines (65 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef __TEXTRUNNER_H__
#define __TEXTRUNNER_H__
#include "TestCase.h"
#include "TestRunner.h"
template<class T> class TextRunner : public StdOutTestReporter, public TestRunner
{
public:
TextRunner() {};
virtual ~TextRunner() {};
virtual void preTest(TestCase* test)
{
// call our super class preTest first
TestRunner::preTest(test);
*this << "Running test: " << test->getTestName() << "\n";
*this << "==============";
for (size_t l = 0; l < test->getTestName().size(); l++)
{
*this << "=";
}
*this << "\n";
}
virtual void reportPass(TestCase* test)
{
// first, report our success to our base class
TestRunner::reportPass(test);
// provide some output to the user on the success
*this << "Test PASSED" << "\n\n";
};
virtual void reportFail(TestCase* test)
{
// report the test not passing to our base class
TestRunner::reportFail(test);
// now provide some output to the user
*this << "Test FAILED" << "\n\n";
};
virtual void reportFailure(TestCase* test)
{
// report the test failing because of an unexpected exception
TestRunner::reportFailure(test);
// now provide the user some output on this
*this << "[Unexpected exception caused test to fail]" << "\n";
*this << "Test FAILED" << "\n\n";
}
virtual void reportResults()
{
*this << "\n" << "Test execution summary:" << "\n";
*this << getPassedTest() << " tests passed" << "\n";
*this << getFailedTest() << " tests failed" << "\n";
*this << getFailures() << " test had failures (i.e. failed to execute)" << "\n";
if ((getFailedTest() > 0) || (getFailures() > 0))
{
*this << "\n" << "TEST FAILED!!!" << "\n";
}
else
{
*this << "\n" << "TEST PASSED!!!" << "\n";
}
}
virtual TestSuite getTests()
{
return T::suite();
}
private:
};
#endif