mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Integrated new section tracker.
- also pass extra section to reporter - one for each test case - ignore it in headers (this is so we know a test case has restarted) - significant effect on regression test due to change of ordering of sections - fixes infinite loop issue
This commit is contained in:
@@ -271,12 +271,10 @@ namespace Catch {
|
||||
sections.push_back( section );
|
||||
|
||||
// Sections
|
||||
if( !sections.empty() ) {
|
||||
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
|
||||
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it )
|
||||
printHeaderString( (*it)->name, 2 );
|
||||
|
||||
}
|
||||
std::vector<ThreadedSectionInfo*>::const_reverse_iterator
|
||||
it = sections.rbegin(), itEnd = sections.rend();
|
||||
for( ++it; it != itEnd; ++it ) // Skip first section (test case)
|
||||
printHeaderString( (*it)->name, 2 );
|
||||
}
|
||||
SourceLineInfo lineInfo = currentSectionInfo
|
||||
? currentSectionInfo->lineInfo
|
||||
|
@@ -16,7 +16,7 @@
|
||||
namespace Catch {
|
||||
class XmlReporter : public SharedImpl<IReporter> {
|
||||
public:
|
||||
XmlReporter( ReporterConfig const& config ) : m_config( config ) {}
|
||||
XmlReporter( ReporterConfig const& config ) : m_config( config ), m_sectionDepth( 0 ) {}
|
||||
|
||||
static std::string getDescription() {
|
||||
return "Reports test results as an XML document";
|
||||
@@ -56,18 +56,22 @@ namespace Catch {
|
||||
}
|
||||
|
||||
virtual void StartSection( const std::string& sectionName, const std::string& description ) {
|
||||
m_xml.startElement( "Section" )
|
||||
.writeAttribute( "name", sectionName )
|
||||
.writeAttribute( "description", description );
|
||||
if( m_sectionDepth++ > 0 ) {
|
||||
m_xml.startElement( "Section" )
|
||||
.writeAttribute( "name", sectionName )
|
||||
.writeAttribute( "description", description );
|
||||
}
|
||||
}
|
||||
virtual void NoAssertionsInSection( const std::string& ) {}
|
||||
virtual void NoAssertionsInTestCase( const std::string& ) {}
|
||||
|
||||
virtual void EndSection( const std::string& /*sectionName*/, const Counts& assertions ) {
|
||||
m_xml.scopedElement( "OverallResults" )
|
||||
.writeAttribute( "successes", assertions.passed )
|
||||
.writeAttribute( "failures", assertions.failed );
|
||||
m_xml.endElement();
|
||||
if( --m_sectionDepth > 0 ) {
|
||||
m_xml.scopedElement( "OverallResults" )
|
||||
.writeAttribute( "successes", assertions.passed )
|
||||
.writeAttribute( "failures", assertions.failed );
|
||||
m_xml.endElement();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void StartTestCase( const Catch::TestCaseInfo& testInfo ) {
|
||||
@@ -138,6 +142,7 @@ namespace Catch {
|
||||
ReporterConfig m_config;
|
||||
bool m_currentTestSuccess;
|
||||
XmlWriter m_xml;
|
||||
int m_sectionDepth;
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
Reference in New Issue
Block a user