Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::TeamCityReporter Struct Reference

#include <catch_reporter_teamcity.hpp>

Inheritance diagram for Catch::TeamCityReporter:
Collaboration diagram for Catch::TeamCityReporter:

Public Member Functions

 TeamCityReporter (ReporterConfig const &_config)
 
 ~TeamCityReporter () override
 
void skipTest (TestCaseInfo const &) override
 
void noMatchingTestCases (std::string const &) override
 
void testGroupStarting (GroupInfo const &groupInfo) override
 
void testGroupEnded (TestGroupStats const &testGroupStats) override
 
void assertionStarting (AssertionInfo const &) override
 
bool assertionEnded (AssertionStats const &assertionStats) override
 
void sectionStarting (SectionInfo const &sectionInfo) override
 
void testCaseStarting (TestCaseInfo const &testInfo) override
 
void testCaseEnded (TestCaseStats const &testCaseStats) override
 
 TeamCityReporter (ReporterConfig const &_config)
 
 ~TeamCityReporter () override
 
void skipTest (TestCaseInfo const &) override
 
void noMatchingTestCases (std::string const &) override
 
void testGroupStarting (GroupInfo const &groupInfo) override
 
void testGroupEnded (TestGroupStats const &testGroupStats) override
 
void assertionStarting (AssertionInfo const &) override
 
bool assertionEnded (AssertionStats const &assertionStats) override
 
void sectionStarting (SectionInfo const &sectionInfo) override
 
void testCaseStarting (TestCaseInfo const &testInfo) override
 
void testCaseEnded (TestCaseStats const &testCaseStats) override
 
- Public Member Functions inherited from Catch::StreamingReporterBase< TeamCityReporter >
 StreamingReporterBase (ReporterConfig const &_config)
 
ReporterPreferences getPreferences () const override
 
 ~StreamingReporterBase () override=default
 
void testRunStarting (TestRunInfo const &_testRunInfo) override
 
void sectionEnded (SectionStats const &) override
 
void testRunEnded (TestRunStats const &) override
 
- Public Member Functions inherited from Catch::IStreamingReporter
virtual ~IStreamingReporter ()=default
 
virtual void benchmarkStarting (BenchmarkInfo const &)
 
virtual void benchmarkEnded (BenchmarkStats const &)
 
virtual void fatalErrorEncountered (StringRef name)
 
virtual bool isMulti () const
 

Static Public Member Functions

static std::string escape (std::string const &str)
 
static std::string getDescription ()
 
static std::string escape (std::string const &str)
 
static std::string getDescription ()
 
- Static Public Member Functions inherited from Catch::StreamingReporterBase< TeamCityReporter >
static std::set< VerbositygetSupportedVerbosities ()
 

Additional Inherited Members

- Public Attributes inherited from Catch::StreamingReporterBase< TeamCityReporter >
IConfigPtr m_config
 
std::ostream & stream
 
LazyStat< TestRunInfocurrentTestRunInfo
 
LazyStat< GroupInfocurrentGroupInfo
 
LazyStat< TestCaseInfocurrentTestCaseInfo
 
std::vector< SectionInfom_sectionStack
 
ReporterPreferences m_reporterPrefs
 

Detailed Description

Definition at line 26 of file catch_reporter_teamcity.hpp.

Constructor & Destructor Documentation

◆ TeamCityReporter() [1/2]

Catch::TeamCityReporter::TeamCityReporter ( ReporterConfig const & _config)
inline

◆ ~TeamCityReporter() [1/2]

Catch::TeamCityReporter::~TeamCityReporter ( )
override

◆ TeamCityReporter() [2/2]

Catch::TeamCityReporter::TeamCityReporter ( ReporterConfig const & _config)
inline

Definition at line 27 of file catch_reporter_teamcity.hpp.

28 : StreamingReporterBase( _config )
29 {
31 }

◆ ~TeamCityReporter() [2/2]

Catch::TeamCityReporter::~TeamCityReporter ( )
override

Member Function Documentation

◆ assertionEnded() [1/2]

bool Catch::TeamCityReporter::assertionEnded ( AssertionStats const & assertionStats)
inlineoverridevirtual

Implements Catch::IStreamingReporter.

Definition at line 68 of file catch_reporter_teamcity.hpp.

68 {
69 AssertionResult const& result = assertionStats.assertionResult;
70 if( !result.isOk() ) {
71
72 ReusableStringStream msg;
73 if( !m_headerPrintedForThisSection )
74 printSectionHeader( msg.get() );
75 m_headerPrintedForThisSection = true;
76
77 msg << result.getSourceInfo() << "\n";
78
79 switch( result.getResultType() ) {
81 msg << "expression failed";
82 break;
84 msg << "unexpected exception";
85 break;
87 msg << "fatal error condition";
88 break;
90 msg << "no exception was thrown where one was expected";
91 break;
93 msg << "explicit failure";
94 break;
95
96 // We shouldn't get here because of the isOk() test
97 case ResultWas::Ok:
98 case ResultWas::Info:
100 CATCH_ERROR( "Internal error in TeamCity reporter" );
101 // These cases are here to prevent compiler warnings
105 CATCH_ERROR( "Not implemented" );
106 }
107 if( assertionStats.infoMessages.size() == 1 )
108 msg << " with message:";
109 if( assertionStats.infoMessages.size() > 1 )
110 msg << " with messages:";
111 for( auto const& messageInfo : assertionStats.infoMessages )
112 msg << "\n \"" << messageInfo.message << "\"";
113
114
115 if( result.hasExpression() ) {
116 msg <<
117 "\n " << result.getExpressionInMacro() << "\n"
118 "with expansion:\n" <<
119 " " << result.getExpandedExpression() << "\n";
120 }
121
122 if( currentTestCaseInfo->okToFail() ) {
123 msg << "- failure ignore as test marked as 'ok to fail'\n";
124 stream << "##teamcity[testIgnored"
125 << " name='" << escape( currentTestCaseInfo->name )<< "'"
126 << " message='" << escape( msg.str() ) << "'"
127 << "]\n";
128 }
129 else {
130 stream << "##teamcity[testFailed"
131 << " name='" << escape( currentTestCaseInfo->name )<< "'"
132 << " message='" << escape( msg.str() ) << "'"
133 << "]\n";
134 }
135 }
136 stream.flush();
137 return true;
138 }
#define CATCH_ERROR(msg)
static std::string escape(std::string const &str)
Here is the call graph for this function:

◆ assertionEnded() [2/2]

bool Catch::TeamCityReporter::assertionEnded ( AssertionStats const & assertionStats)
inlineoverridevirtual

Implements Catch::IStreamingReporter.

Definition at line 68 of file catch_reporter_teamcity.hpp.

68 {
69 AssertionResult const& result = assertionStats.assertionResult;
70 if( !result.isOk() ) {
71
72 ReusableStringStream msg;
73 if( !m_headerPrintedForThisSection )
74 printSectionHeader( msg.get() );
75 m_headerPrintedForThisSection = true;
76
77 msg << result.getSourceInfo() << "\n";
78
79 switch( result.getResultType() ) {
81 msg << "expression failed";
82 break;
84 msg << "unexpected exception";
85 break;
87 msg << "fatal error condition";
88 break;
90 msg << "no exception was thrown where one was expected";
91 break;
93 msg << "explicit failure";
94 break;
95
96 // We shouldn't get here because of the isOk() test
97 case ResultWas::Ok:
98 case ResultWas::Info:
100 CATCH_ERROR( "Internal error in TeamCity reporter" );
101 // These cases are here to prevent compiler warnings
105 CATCH_ERROR( "Not implemented" );
106 }
107 if( assertionStats.infoMessages.size() == 1 )
108 msg << " with message:";
109 if( assertionStats.infoMessages.size() > 1 )
110 msg << " with messages:";
111 for( auto const& messageInfo : assertionStats.infoMessages )
112 msg << "\n \"" << messageInfo.message << "\"";
113
114
115 if( result.hasExpression() ) {
116 msg <<
117 "\n " << result.getExpressionInMacro() << "\n"
118 "with expansion:\n" <<
119 " " << result.getExpandedExpression() << "\n";
120 }
121
122 if( currentTestCaseInfo->okToFail() ) {
123 msg << "- failure ignore as test marked as 'ok to fail'\n";
124 stream << "##teamcity[testIgnored"
125 << " name='" << escape( currentTestCaseInfo->name )<< "'"
126 << " message='" << escape( msg.str() ) << "'"
127 << "]\n";
128 }
129 else {
130 stream << "##teamcity[testFailed"
131 << " name='" << escape( currentTestCaseInfo->name )<< "'"
132 << " message='" << escape( msg.str() ) << "'"
133 << "]\n";
134 }
135 }
136 stream.flush();
137 return true;
138 }
Here is the call graph for this function:

◆ assertionStarting() [1/2]

void Catch::TeamCityReporter::assertionStarting ( AssertionInfo const & )
inlineoverridevirtual

Implements Catch::IStreamingReporter.

Definition at line 66 of file catch_reporter_teamcity.hpp.

66{}

◆ assertionStarting() [2/2]

void Catch::TeamCityReporter::assertionStarting ( AssertionInfo const & )
inlineoverridevirtual

Implements Catch::IStreamingReporter.

Definition at line 66 of file catch_reporter_teamcity.hpp.

66{}

◆ escape() [1/2]

static std::string Catch::TeamCityReporter::escape ( std::string const & str)
inlinestatic

Definition at line 33 of file catch_reporter_teamcity.hpp.

33 {
34 std::string escaped = str;
35 replaceInPlace( escaped, "|", "||" );
36 replaceInPlace( escaped, "'", "|'" );
37 replaceInPlace( escaped, "\n", "|n" );
38 replaceInPlace( escaped, "\r", "|r" );
39 replaceInPlace( escaped, "[", "|[" );
40 replaceInPlace( escaped, "]", "|]" );
41 return escaped;
42 }
return str
Definition CLI11.hpp:1359
bool replaceInPlace(std::string &str, std::string const &replaceThis, std::string const &withThis)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ escape() [2/2]

static std::string Catch::TeamCityReporter::escape ( std::string const & str)
inlinestatic

Definition at line 33 of file catch_reporter_teamcity.hpp.

33 {
34 std::string escaped = str;
35 replaceInPlace( escaped, "|", "||" );
36 replaceInPlace( escaped, "'", "|'" );
37 replaceInPlace( escaped, "\n", "|n" );
38 replaceInPlace( escaped, "\r", "|r" );
39 replaceInPlace( escaped, "[", "|[" );
40 replaceInPlace( escaped, "]", "|]" );
41 return escaped;
42 }
Here is the call graph for this function:

◆ getDescription() [1/2]

static std::string Catch::TeamCityReporter::getDescription ( )
inlinestatic

Definition at line 45 of file catch_reporter_teamcity.hpp.

45 {
46 return "Reports test results as TeamCity service messages";
47 }

◆ getDescription() [2/2]

static std::string Catch::TeamCityReporter::getDescription ( )
inlinestatic

Definition at line 45 of file catch_reporter_teamcity.hpp.

45 {
46 return "Reports test results as TeamCity service messages";
47 }

◆ noMatchingTestCases() [1/2]

void Catch::TeamCityReporter::noMatchingTestCases ( std::string const & )
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 52 of file catch_reporter_teamcity.hpp.

52{}

◆ noMatchingTestCases() [2/2]

void Catch::TeamCityReporter::noMatchingTestCases ( std::string const & )
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 52 of file catch_reporter_teamcity.hpp.

52{}

◆ sectionStarting() [1/2]

void Catch::TeamCityReporter::sectionStarting ( SectionInfo const & sectionInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 140 of file catch_reporter_teamcity.hpp.

140 {
141 m_headerPrintedForThisSection = false;
143 }
void sectionStarting(SectionInfo const &_sectionInfo) override
Here is the call graph for this function:

◆ sectionStarting() [2/2]

void Catch::TeamCityReporter::sectionStarting ( SectionInfo const & sectionInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 140 of file catch_reporter_teamcity.hpp.

140 {
141 m_headerPrintedForThisSection = false;
143 }
Here is the call graph for this function:

◆ skipTest() [1/2]

void Catch::TeamCityReporter::skipTest ( TestCaseInfo const & )
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 49 of file catch_reporter_teamcity.hpp.

49 {
50 }

◆ skipTest() [2/2]

void Catch::TeamCityReporter::skipTest ( TestCaseInfo const & )
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 49 of file catch_reporter_teamcity.hpp.

49 {
50 }

◆ testCaseEnded() [1/2]

void Catch::TeamCityReporter::testCaseEnded ( TestCaseStats const & testCaseStats)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 153 of file catch_reporter_teamcity.hpp.

153 {
155 if( !testCaseStats.stdOut.empty() )
156 stream << "##teamcity[testStdOut name='"
157 << escape( testCaseStats.testInfo.name )
158 << "' out='" << escape( testCaseStats.stdOut ) << "']\n";
159 if( !testCaseStats.stdErr.empty() )
160 stream << "##teamcity[testStdErr name='"
161 << escape( testCaseStats.testInfo.name )
162 << "' out='" << escape( testCaseStats.stdErr ) << "']\n";
163 stream << "##teamcity[testFinished name='"
164 << escape( testCaseStats.testInfo.name ) << "' duration='"
165 << m_testTimer.getElapsedMilliseconds() << "']\n";
166 stream.flush();
167 }
auto getElapsedMilliseconds() const -> unsigned int
void testCaseEnded(TestCaseStats const &) override
Here is the call graph for this function:

◆ testCaseEnded() [2/2]

void Catch::TeamCityReporter::testCaseEnded ( TestCaseStats const & testCaseStats)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 153 of file catch_reporter_teamcity.hpp.

153 {
155 if( !testCaseStats.stdOut.empty() )
156 stream << "##teamcity[testStdOut name='"
157 << escape( testCaseStats.testInfo.name )
158 << "' out='" << escape( testCaseStats.stdOut ) << "']\n";
159 if( !testCaseStats.stdErr.empty() )
160 stream << "##teamcity[testStdErr name='"
161 << escape( testCaseStats.testInfo.name )
162 << "' out='" << escape( testCaseStats.stdErr ) << "']\n";
163 stream << "##teamcity[testFinished name='"
164 << escape( testCaseStats.testInfo.name ) << "' duration='"
165 << m_testTimer.getElapsedMilliseconds() << "']\n";
166 stream.flush();
167 }
Here is the call graph for this function:

◆ testCaseStarting() [1/2]

void Catch::TeamCityReporter::testCaseStarting ( TestCaseInfo const & testInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 145 of file catch_reporter_teamcity.hpp.

145 {
146 m_testTimer.start();
148 stream << "##teamcity[testStarted name='"
149 << escape( testInfo.name ) << "']\n";
150 stream.flush();
151 }
void testCaseStarting(TestCaseInfo const &_testInfo) override
Here is the call graph for this function:

◆ testCaseStarting() [2/2]

void Catch::TeamCityReporter::testCaseStarting ( TestCaseInfo const & testInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 145 of file catch_reporter_teamcity.hpp.

145 {
146 m_testTimer.start();
148 stream << "##teamcity[testStarted name='"
149 << escape( testInfo.name ) << "']\n";
150 stream.flush();
151 }
Here is the call graph for this function:

◆ testGroupEnded() [1/2]

void Catch::TeamCityReporter::testGroupEnded ( TestGroupStats const & testGroupStats)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 59 of file catch_reporter_teamcity.hpp.

59 {
61 stream << "##teamcity[testSuiteFinished name='"
62 << escape( testGroupStats.groupInfo.name ) << "']\n";
63 }
void testGroupEnded(TestGroupStats const &) override
Here is the call graph for this function:

◆ testGroupEnded() [2/2]

void Catch::TeamCityReporter::testGroupEnded ( TestGroupStats const & testGroupStats)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 59 of file catch_reporter_teamcity.hpp.

59 {
61 stream << "##teamcity[testSuiteFinished name='"
62 << escape( testGroupStats.groupInfo.name ) << "']\n";
63 }
Here is the call graph for this function:

◆ testGroupStarting() [1/2]

void Catch::TeamCityReporter::testGroupStarting ( GroupInfo const & groupInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 54 of file catch_reporter_teamcity.hpp.

54 {
56 stream << "##teamcity[testSuiteStarted name='"
57 << escape( groupInfo.name ) << "']\n";
58 }
void testGroupStarting(GroupInfo const &_groupInfo) override
Here is the call graph for this function:

◆ testGroupStarting() [2/2]

void Catch::TeamCityReporter::testGroupStarting ( GroupInfo const & groupInfo)
inlineoverridevirtual

Reimplemented from Catch::StreamingReporterBase< TeamCityReporter >.

Definition at line 54 of file catch_reporter_teamcity.hpp.

54 {
56 stream << "##teamcity[testSuiteStarted name='"
57 << escape( groupInfo.name ) << "']\n";
58 }
Here is the call graph for this function:

The documentation for this struct was generated from the following files: