Jon Test
C++ Unit Test Tool. Not for production -- sample code only
Loading...
Searching...
No Matches
Logger.cpp
Go to the documentation of this file.
1#include "JonTest/Logger.h"
2
4
5#include <ostream>
6#include <string>
7
8namespace JonTest
9{
10
12{
13 // Nothing to do
14}
15
17 std::ostream& out,
18 bool verbose
19)
20:out(out),
21verbose(verbose)
22{
23}
24
26{
27 // Nothing to do
28}
29
31{
32 if(verbose)
33 {
34 out << "Beginning All Test Suites" << std::endl;
35 }
36}
37
39 const std::string& suiteName
40)
41{
42 if(verbose)
43 {
44 out << "Beginning Suite: " << suiteName << "\n";
45 }
46}
47
49 const std::string& suiteName,
50 const std::string& caseName
51)
52{
53 if(verbose)
54 {
55 out << "\t" << suiteName << ":" << caseName << ": start" <<"\n";
56 }
57}
58
60 const std::string& suiteName,
61 const std::string& caseName,
62 const std::string& casePart,
63 const std::string& message
64)
65{
66 out << "\t" << suiteName << ":" << caseName << ": " << casePart
67 << " " << message << "\n";
68}
69
71 const std::string& suiteName,
72 const std::string& caseName,
73 const std::string& casePart,
74 const TestFailure& failure
75)
76{
77 out << "\t" << suiteName << ":" << caseName << ": " << casePart
78 << " FAILED: " << failure.what() << "\n";
79}
80
82 const std::string& suiteName,
83 const std::string& caseName,
84 const std::string& casePart,
85 const std::exception& unexpected
86)
87{
88 out << "\t" << suiteName << ":" << caseName << ": " << casePart
89 << " UNEXPECTED EXCEPTION: " << unexpected.what() << "\n";
90}
91
93 const std::string& suiteName,
94 const std::string& caseName,
95 const bool pass
96)
97{
98 if(verbose)
99 {
100 out << "\t" << suiteName << ":" << caseName << ": done "
101 << (pass ? "passed" : "FAILED") <<"\n";
102 }
103}
104
106 const std::string& suiteName,
107 const Count& count
108)
109{
110 if(verbose)
111 {
112 out << "Suite Complete: " << suiteName << "\n"
113 << "\tRun: " << count.count << "\t Fails: " << count.fails << "\n\n";
114 }
115}
116
118 const Count& count
119)
120{
121 out << "Tests Complete:\t\tRun: " << count.count << "\t\tFails: " << count.fails << std::endl;
122}
123
124}
Count of tests run, and fails.
Definition Count.h:10
int fails
Number of tests that have failed.
Definition Count.h:18
int count
Number of tests that have been run.
Definition Count.h:14
virtual ~Logger()
Destructor – does nothing.
Definition Logger.cpp:11
virtual void end(const Count &count)
End of all testing, suitable to output.
Definition Logger.cpp:117
virtual void endSuite(const std::string &suiteName, const Count &count)
End of test suite, with count of tests run and failed for that suite alone.
Definition Logger.cpp:105
const bool verbose
Simple level of verbosity: true for all events, false for critical.
Definition Logger.h:95
virtual void failCase(const std::string &suiteName, const std::string &caseName, const std::string &casePart, const TestFailure &failure)
Test failure occurred during a part of the case.
Definition Logger.cpp:70
virtual void start()
Start of all testing.
Definition Logger.cpp:30
virtual ~StreamLogger()
Destructor – does nothing.
Definition Logger.cpp:25
virtual void startCase(const std::string &suiteName, const std::string &caseName)
Start of test case.
Definition Logger.cpp:48
virtual void startSuite(const std::string &suiteName)
Start of test suite.
Definition Logger.cpp:38
StreamLogger(std::ostream &out, bool verbose)
Construct the Stream Logger to write to out with the given verbosity.
Definition Logger.cpp:16
virtual void exceptionCase(const std::string &suiteName, const std::string &caseName, const std::string &casePart, const std::exception &unexpected)
Unexpected exception occurred during a part of the case.
Definition Logger.cpp:81
virtual void errorCase(const std::string &suiteName, const std::string &caseName, const std::string &casePart, const std::string &message)
Unexpected error occurred during a part of the test case.
Definition Logger.cpp:59
std::ostream & out
Stream to write to.
Definition Logger.h:92
virtual void endCase(const std::string &suiteName, const std::string &caseName, const bool pass)
End of test case, with record pass or fail.
Definition Logger.cpp:92
Defines and runs a single Test Case within a Test Suite.
Definition TestCase.h:18
Exception thrown when a test fails an assert and should fail (unless wrapped in expectedFailure()).
Definition TestFailure.h:17
Definition Count.h:5