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
21TestReporter::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
36
38{
39 return m_ok;
40}
41
43{
44 return m_fail;
45}
46
48{
49 return m_skip;
50}
51
53{
54 m_report = value;
55}
56
58{
59 m_statistics = value;
60}
61
62void 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}
Simple linked list template class.
Definition List.h:37
Represents a test instance.
void setMultiline(bool value)
Set multine mode on/off.
virtual ~TestReporter()
Destructor.
TestReporter(int argc, char **argv)
Constructor.
bool m_statistics
Final statistics on/off.
int m_argc
Argument count.
virtual void prepare(TestInstance &test)
Prepare for next test.
virtual void begin(List< TestInstance * > &tests)
Begin testing.
uint m_ok
Test statistics.
char ** m_argv
Argument values.
void setReport(bool value)
Set reporting on/off.
virtual void reportFinish(List< TestInstance * > &tests)=0
Report completion of all tests.
uint getFailed() const
Get fail count.
void setStatistics(bool value)
Set final statistics on/off.
virtual void reportAfter(TestInstance &test, TestResult &result)=0
Report finish of a test.
virtual void finish(List< TestInstance * > &tests)
Finish testing.
virtual void reportBefore(TestInstance &test)=0
Report start of a test.
uint getSkipped() const
Get skip count.
virtual void collect(TestInstance &test, TestResult &result)
Collect test statistics.
bool m_report
Report on/off.
uint getOk() const
Get OK count.
virtual void reportBegin(List< TestInstance * > &tests)=0
Report start of testing.
bool m_multiline
Multi line output.
Represents a Test result created by a TestInstance.
Definition TestResult.h:48
bool isFailed() const
Check if the test failed.
bool isOK() const
Check if the test passed.
bool isSkipped() const
Check if the test is skipped.
unsigned int uint
Unsigned integer number.
Definition Types.h:44