FreeNOS
TestReporter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <string.h>
19 #include "TestReporter.h"
20 
21 TestReporter::TestReporter(int argc, char **argv)
22 {
23  m_argc = argc;
24  m_argv = argv;
25  m_ok = 0;
26  m_fail = 0;
27  m_skip = 0;
28  m_report = true;
29  m_statistics = true;
30  m_multiline = false;
31 }
32 
34 {
35 }
36 
38 {
39  return m_ok;
40 }
41 
43 {
44  return m_fail;
45 }
46 
48 {
49  return m_skip;
50 }
51 
52 void TestReporter::setReport(bool value)
53 {
54  m_report = value;
55 }
56 
58 {
59  m_statistics = value;
60 }
61 
62 void TestReporter::setMultiline(bool multiline)
63 {
64  m_multiline = multiline;
65 }
66 
68 {
69  if (m_report)
70  reportBefore(test);
71 }
72 
74 {
75  if (m_report)
76  reportAfter(test, result);
77 
78  if (result.isOK())
79  m_ok++;
80 
81  if (result.isFailed())
82  m_fail++;
83 
84  if (result.isSkipped())
85  m_skip++;
86 }
87 
89 {
90  if (m_report)
91  reportBegin(tests);
92 }
93 
95 {
96  if (m_statistics)
97  reportFinish(tests);
98 }
TestReporter::reportBefore
virtual void reportBefore(TestInstance &test)=0
Report start of a test.
TestReporter::~TestReporter
virtual ~TestReporter()
Destructor.
Definition: TestReporter.cpp:33
string.h
TestReporter::m_argc
int m_argc
Argument count.
Definition: TestReporter.h:124
TestReporter::getOk
uint getOk() const
Get OK count.
Definition: TestReporter.cpp:37
TestResult::isOK
bool isOK() const
Check if the test passed.
Definition: TestResult.cpp:25
TestReporter::m_skip
uint m_skip
Definition: TestReporter.h:139
TestReporter::begin
virtual void begin(List< TestInstance * > &tests)
Begin testing.
Definition: TestReporter.cpp:88
TestReporter::m_statistics
bool m_statistics
Final statistics on/off.
Definition: TestReporter.h:133
TestReporter::m_multiline
bool m_multiline
Multi line output.
Definition: TestReporter.h:136
TestReporter::finish
virtual void finish(List< TestInstance * > &tests)
Finish testing.
Definition: TestReporter.cpp:94
uint
unsigned int uint
Unsigned integer number.
Definition: Types.h:44
TestReporter::getSkipped
uint getSkipped() const
Get skip count.
Definition: TestReporter.cpp:47
TestReporter::m_fail
uint m_fail
Definition: TestReporter.h:139
TestResult::isSkipped
bool isSkipped() const
Check if the test is skipped.
Definition: TestResult.cpp:35
TestReporter::prepare
virtual void prepare(TestInstance &test)
Prepare for next test.
Definition: TestReporter.cpp:67
TestReporter::m_argv
char ** m_argv
Argument values.
Definition: TestReporter.h:127
TestReporter::m_ok
uint m_ok
Test statistics.
Definition: TestReporter.h:139
TestReporter::collect
virtual void collect(TestInstance &test, TestResult &result)
Collect test statistics.
Definition: TestReporter.cpp:73
TestReporter::reportBegin
virtual void reportBegin(List< TestInstance * > &tests)=0
Report start of testing.
TestReporter::setMultiline
void setMultiline(bool value)
Set multine mode on/off.
Definition: TestReporter.cpp:62
TestReporter::TestReporter
TestReporter(int argc, char **argv)
Constructor.
Definition: TestReporter.cpp:21
TestResult
Represents a Test result created by a TestInstance.
Definition: TestResult.h:47
TestResult::isFailed
bool isFailed() const
Check if the test failed.
Definition: TestResult.cpp:30
TestReporter::reportFinish
virtual void reportFinish(List< TestInstance * > &tests)=0
Report completion of all tests.
TestReporter::setReport
void setReport(bool value)
Set reporting on/off.
Definition: TestReporter.cpp:52
TestReporter.h
TestReporter::reportAfter
virtual void reportAfter(TestInstance &test, TestResult &result)=0
Report finish of a test.
TestReporter::m_report
bool m_report
Report on/off.
Definition: TestReporter.h:130
List< TestInstance * >
TestReporter::setStatistics
void setStatistics(bool value)
Set final statistics on/off.
Definition: TestReporter.cpp:57
TestReporter::getFailed
uint getFailed() const
Get fail count.
Definition: TestReporter.cpp:42
TestInstance
Represents a test instance.
Definition: TestInstance.h:35