8#ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
9#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
20# pragma clang diagnostic push
21# pragma clang diagnostic ignored "-Wpadded"
33 static std::string
escape( std::string
const& str ) {
34 std::string escaped = str;
46 return "Reports test results as TeamCity service messages";
56 stream <<
"##teamcity[testSuiteStarted name='"
61 stream <<
"##teamcity[testSuiteFinished name='"
70 if( !result.isOk() ) {
73 if( !m_headerPrintedForThisSection )
74 printSectionHeader( msg.
get() );
75 m_headerPrintedForThisSection =
true;
77 msg << result.getSourceInfo() <<
"\n";
79 switch( result.getResultType() ) {
81 msg <<
"expression failed";
84 msg <<
"unexpected exception";
87 msg <<
"fatal error condition";
90 msg <<
"no exception was thrown where one was expected";
93 msg <<
"explicit failure";
100 CATCH_ERROR(
"Internal error in TeamCity reporter" );
108 msg <<
" with message:";
110 msg <<
" with messages:";
111 for(
auto const& messageInfo : assertionStats.
infoMessages )
112 msg <<
"\n \"" << messageInfo.message <<
"\"";
115 if( result.hasExpression() ) {
117 "\n " << result.getExpressionInMacro() <<
"\n"
118 "with expansion:\n" <<
119 " " << result.getExpandedExpression() <<
"\n";
123 msg <<
"- failure ignore as test marked as 'ok to fail'\n";
124 stream <<
"##teamcity[testIgnored"
126 <<
" message='" <<
escape( msg.
str() ) <<
"'"
130 stream <<
"##teamcity[testFailed"
132 <<
" message='" <<
escape( msg.
str() ) <<
"'"
141 m_headerPrintedForThisSection =
false;
148 stream <<
"##teamcity[testStarted name='"
155 if( !testCaseStats.
stdOut.empty() )
156 stream <<
"##teamcity[testStdOut name='"
158 <<
"' out='" <<
escape( testCaseStats.
stdOut ) <<
"']\n";
159 if( !testCaseStats.
stdErr.empty() )
160 stream <<
"##teamcity[testStdErr name='"
162 <<
"' out='" <<
escape( testCaseStats.
stdErr ) <<
"']\n";
163 stream <<
"##teamcity[testFinished name='"
170 void printSectionHeader( std::ostream&
os ) {
176 std::vector<SectionInfo>::const_iterator
179 for( ; it != itEnd; ++it )
180 printHeaderString(
os, it->name );
186 if( !lineInfo.empty() )
187 os << lineInfo <<
"\n";
193 static void printHeaderString( std::ostream&
os, std::string
const& _string, std::size_t indent = 0 ) {
194 std::size_t i = _string.find(
": " );
195 if( i != std::string::npos )
199 os << Column( _string )
201 .initialIndent( indent ) <<
"\n";
204 bool m_headerPrintedForThisSection =
false;
217# pragma clang diagnostic pop
#define CATCH_REGISTER_REPORTER(name, reporterType)
auto str() const -> std::string
auto get() -> std::ostream &
auto getElapsedMilliseconds() const -> unsigned int
char const * getLineOfChars()
bool replaceInPlace(std::string &str, std::string const &replaceThis, std::string const &withThis)
std::vector< MessageInfo > infoMessages
AssertionResult assertionResult
bool shouldRedirectStdOut
void sectionStarting(SectionInfo const &_sectionInfo) override
std::vector< SectionInfo > m_sectionStack
void testGroupStarting(GroupInfo const &_groupInfo) override
LazyStat< TestCaseInfo > currentTestCaseInfo
ReporterPreferences m_reporterPrefs
void testCaseStarting(TestCaseInfo const &_testInfo) override
void testCaseEnded(TestCaseStats const &) override
void testGroupEnded(TestGroupStats const &) override
void noMatchingTestCases(std::string const &) override
void testGroupEnded(TestGroupStats const &testGroupStats) override
void assertionStarting(AssertionInfo const &) override
void skipTest(TestCaseInfo const &) override
void testCaseStarting(TestCaseInfo const &testInfo) override
static std::string escape(std::string const &str)
bool assertionEnded(AssertionStats const &assertionStats) override
void sectionStarting(SectionInfo const §ionInfo) override
void testGroupStarting(GroupInfo const &groupInfo) override
~TeamCityReporter() override
TeamCityReporter(ReporterConfig const &_config)
static std::string getDescription()
void testCaseEnded(TestCaseStats const &testCaseStats) override