Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_interfaces_reporter.h
Go to the documentation of this file.
1/*
2 * Created by Phil on 31/12/2010.
3 * Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
4 *
5 * Distributed under the Boost Software License, Version 1.0. (See accompanying
6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 */
8#ifndef TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
9#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
10
11#include "catch_section_info.h"
12#include "catch_common.h"
13#include "catch_config.hpp"
14#include "catch_totals.h"
17#include "catch_message.h"
18#include "catch_option.hpp"
19#include "catch_stringref.h"
20
21
22#include <string>
23#include <iosfwd>
24#include <map>
25#include <set>
26#include <memory>
27
28namespace Catch {
29
31 explicit ReporterConfig( IConfigPtr const& _fullConfig );
32
33 ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream );
34
35 std::ostream& stream() const;
36 IConfigPtr fullConfig() const;
37
38 private:
39 std::ostream* m_stream;
40 IConfigPtr m_fullConfig;
41 };
42
47
48 template<typename T>
49 struct LazyStat : Option<T> {
50 LazyStat& operator=( T const& _value ) {
51 Option<T>::operator=( _value );
52 used = false;
53 return *this;
54 }
55 void reset() {
57 used = false;
58 }
59 bool used = false;
60 };
61
62 struct TestRunInfo {
63 TestRunInfo( std::string const& _name );
64 std::string name;
65 };
66 struct GroupInfo {
67 GroupInfo( std::string const& _name,
68 std::size_t _groupIndex,
69 std::size_t _groupsCount );
70
71 std::string name;
72 std::size_t groupIndex;
73 std::size_t groupsCounts;
74 };
75
77 AssertionStats( AssertionResult const& _assertionResult,
78 std::vector<MessageInfo> const& _infoMessages,
79 Totals const& _totals );
80
81 AssertionStats( AssertionStats const& ) = default;
85 virtual ~AssertionStats();
86
88 std::vector<MessageInfo> infoMessages;
90 };
91
92 struct SectionStats {
93 SectionStats( SectionInfo const& _sectionInfo,
94 Counts const& _assertions,
95 double _durationInSeconds,
96 bool _missingAssertions );
97 SectionStats( SectionStats const& ) = default;
98 SectionStats( SectionStats && ) = default;
101 virtual ~SectionStats();
102
107 };
108
110 TestCaseStats( TestCaseInfo const& _testInfo,
111 Totals const& _totals,
112 std::string const& _stdOut,
113 std::string const& _stdErr,
114 bool _aborting );
115
116 TestCaseStats( TestCaseStats const& ) = default;
120 virtual ~TestCaseStats();
121
124 std::string stdOut;
125 std::string stdErr;
127 };
128
130 TestGroupStats( GroupInfo const& _groupInfo,
131 Totals const& _totals,
132 bool _aborting );
133 TestGroupStats( GroupInfo const& _groupInfo );
134
135 TestGroupStats( TestGroupStats const& ) = default;
140
144 };
145
147 TestRunStats( TestRunInfo const& _runInfo,
148 Totals const& _totals,
149 bool _aborting );
150
151 TestRunStats( TestRunStats const& ) = default;
152 TestRunStats( TestRunStats && ) = default;
155 virtual ~TestRunStats();
156
160 };
161
163 std::string name;
164 };
170
172 virtual ~IStreamingReporter() = default;
173
174 // Implementing class must also provide the following static methods:
175 // static std::string getDescription();
176 // static std::set<Verbosity> getSupportedVerbosities()
177
179
180 virtual void noMatchingTestCases( std::string const& spec ) = 0;
181
182 virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;
183 virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;
184
185 virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;
186 virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;
187
188 // *** experimental ***
189 virtual void benchmarkStarting( BenchmarkInfo const& ) {}
190
191 virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;
192
193 // The return value indicates if the messages buffer should be cleared:
194 virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
195
196 // *** experimental ***
197 virtual void benchmarkEnded( BenchmarkStats const& ) {}
198
199 virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
200 virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
201 virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
202 virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
203
204 virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
205
206 // Default empty implementation provided
207 virtual void fatalErrorEncountered( StringRef name );
208
209 virtual bool isMulti() const;
210 };
211 using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
212
216 virtual std::string getDescription() const = 0;
217 };
218 using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;
219
221 using FactoryMap = std::map<std::string, IReporterFactoryPtr>;
222 using Listeners = std::vector<IReporterFactoryPtr>;
223
225 virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0;
226 virtual FactoryMap const& getFactories() const = 0;
227 virtual Listeners const& getListeners() const = 0;
228 };
229
230} // end namespace Catch
231
232#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
std::string name
Option & operator=(Option const &_other)
std::unique_ptr< IStreamingReporter > IStreamingReporterPtr
std::shared_ptr< IReporterFactory > IReporterFactoryPtr
std::shared_ptr< IConfig const > IConfigPtr
#define T(meth, val, expected)
unsigned __int64 uint64_t
Definition stdint.h:136
std::vector< MessageInfo > infoMessages
AssertionStats(AssertionStats &&)=default
AssertionStats & operator=(AssertionStats const &)=delete
AssertionStats(AssertionResult const &_assertionResult, std::vector< MessageInfo > const &_infoMessages, Totals const &_totals)
AssertionStats(AssertionStats const &)=default
GroupInfo(std::string const &_name, std::size_t _groupIndex, std::size_t _groupsCount)
virtual std::string getDescription() const =0
virtual IStreamingReporterPtr create(ReporterConfig const &config) const =0
std::map< std::string, IReporterFactoryPtr > FactoryMap
virtual Listeners const & getListeners() const =0
virtual IStreamingReporterPtr create(std::string const &name, IConfigPtr const &config) const =0
std::vector< IReporterFactoryPtr > Listeners
virtual FactoryMap const & getFactories() const =0
virtual void skipTest(TestCaseInfo const &testInfo)=0
virtual ReporterPreferences getPreferences() const =0
virtual void testRunEnded(TestRunStats const &testRunStats)=0
virtual bool assertionEnded(AssertionStats const &assertionStats)=0
virtual ~IStreamingReporter()=default
virtual void testRunStarting(TestRunInfo const &testRunInfo)=0
virtual void testCaseStarting(TestCaseInfo const &testInfo)=0
virtual void sectionStarting(SectionInfo const &sectionInfo)=0
virtual void noMatchingTestCases(std::string const &spec)=0
virtual void sectionEnded(SectionStats const &sectionStats)=0
virtual void testGroupEnded(TestGroupStats const &testGroupStats)=0
virtual void benchmarkStarting(BenchmarkInfo const &)
virtual void fatalErrorEncountered(StringRef name)
virtual void assertionStarting(AssertionInfo const &assertionInfo)=0
virtual void testCaseEnded(TestCaseStats const &testCaseStats)=0
virtual void benchmarkEnded(BenchmarkStats const &)
virtual void testGroupStarting(GroupInfo const &groupInfo)=0
LazyStat & operator=(T const &_value)
ReporterConfig(IConfigPtr const &_fullConfig)
SectionStats(SectionStats &&)=default
SectionStats(SectionStats const &)=default
SectionStats & operator=(SectionStats const &)=default
SectionStats(SectionInfo const &_sectionInfo, Counts const &_assertions, double _durationInSeconds, bool _missingAssertions)
virtual ~SectionStats()
TestCaseStats(TestCaseStats const &)=default
TestCaseStats & operator=(TestCaseStats const &)=default
virtual ~TestCaseStats()
TestCaseStats(TestCaseInfo const &_testInfo, Totals const &_totals, std::string const &_stdOut, std::string const &_stdErr, bool _aborting)
TestCaseStats(TestCaseStats &&)=default
TestGroupStats(TestGroupStats &&)=default
TestGroupStats & operator=(TestGroupStats const &)=default
TestGroupStats(TestGroupStats const &)=default
TestGroupStats(GroupInfo const &_groupInfo, Totals const &_totals, bool _aborting)
TestRunInfo(std::string const &_name)
TestRunStats(TestRunStats const &)=default
TestRunStats(TestRunInfo const &_runInfo, Totals const &_totals, bool _aborting)
TestRunStats(TestRunStats &&)=default
virtual ~TestRunStats()
TestRunStats & operator=(TestRunStats const &)=default