mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Added Listeners (programatically provided extra reporters)
This commit is contained in:
parent
4cb74761d9
commit
368714e7aa
@ -43,6 +43,14 @@ namespace Catch {
|
|||||||
reporter = addReporter( reporter, createReporter( *it, config ) );
|
reporter = addReporter( reporter, createReporter( *it, config ) );
|
||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
Ptr<IStreamingReporter> addListeners( Ptr<IConfig> const& config, Ptr<IStreamingReporter> reporters ) {
|
||||||
|
IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners();
|
||||||
|
for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
|
||||||
|
return reporters;
|
||||||
|
}
|
||||||
|
|
||||||
void openStreamInto( Ptr<Config> const& config, std::ofstream& ofs ) {
|
void openStreamInto( Ptr<Config> const& config, std::ofstream& ofs ) {
|
||||||
// Open output file, if specified
|
// Open output file, if specified
|
||||||
@ -62,7 +70,8 @@ namespace Catch {
|
|||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
openStreamInto( config, ofs );
|
openStreamInto( config, ofs );
|
||||||
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
||||||
|
reporter = addListeners( config.get(), reporter );
|
||||||
|
|
||||||
RunContext context( config.get(), reporter );
|
RunContext context( config.get(), reporter );
|
||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
@ -208,7 +217,6 @@ namespace Catch {
|
|||||||
m_config = new Config( m_configData );
|
m_config = new Config( m_configData );
|
||||||
return *m_config;
|
return *m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Clara::CommandLine<ConfigData> m_cli;
|
Clara::CommandLine<ConfigData> m_cli;
|
||||||
std::vector<Clara::Parser::Token> m_unusedTokens;
|
std::vector<Clara::Parser::Token> m_unusedTokens;
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
|
|
||||||
|
#include <catch_ptr.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@ -29,7 +31,8 @@ namespace Catch {
|
|||||||
|
|
||||||
struct IMutableRegistryHub {
|
struct IMutableRegistryHub {
|
||||||
virtual ~IMutableRegistryHub();
|
virtual ~IMutableRegistryHub();
|
||||||
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0;
|
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) = 0;
|
||||||
|
virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
|
||||||
virtual void registerTest( TestCase const& testInfo ) = 0;
|
virtual void registerTest( TestCase const& testInfo ) = 0;
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||||
};
|
};
|
||||||
|
@ -240,6 +240,7 @@ namespace Catch
|
|||||||
|
|
||||||
// The return value indicates if the messages buffer should be cleared:
|
// The return value indicates if the messages buffer should be cleared:
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
||||||
@ -249,18 +250,20 @@ namespace Catch
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct IReporterFactory {
|
struct IReporterFactory : IShared {
|
||||||
virtual ~IReporterFactory();
|
virtual ~IReporterFactory();
|
||||||
virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
|
||||||
virtual std::string getDescription() const = 0;
|
virtual std::string getDescription() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IReporterRegistry {
|
struct IReporterRegistry {
|
||||||
typedef std::map<std::string, IReporterFactory*> FactoryMap;
|
typedef std::map<std::string, Ptr<IReporterFactory> > FactoryMap;
|
||||||
|
typedef std::vector<Ptr<IReporterFactory> > Listeners;
|
||||||
|
|
||||||
virtual ~IReporterRegistry();
|
virtual ~IReporterRegistry();
|
||||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const = 0;
|
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const = 0;
|
||||||
virtual FactoryMap const& getFactories() const = 0;
|
virtual FactoryMap const& getFactories() const = 0;
|
||||||
|
virtual Listeners const& getListeners() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
|
||||||
|
@ -26,24 +26,27 @@ namespace Catch {
|
|||||||
public: // IRegistryHub
|
public: // IRegistryHub
|
||||||
RegistryHub() {
|
RegistryHub() {
|
||||||
}
|
}
|
||||||
virtual IReporterRegistry const& getReporterRegistry() const {
|
virtual IReporterRegistry const& getReporterRegistry() const override {
|
||||||
return m_reporterRegistry;
|
return m_reporterRegistry;
|
||||||
}
|
}
|
||||||
virtual ITestCaseRegistry const& getTestCaseRegistry() const {
|
virtual ITestCaseRegistry const& getTestCaseRegistry() const override {
|
||||||
return m_testCaseRegistry;
|
return m_testCaseRegistry;
|
||||||
}
|
}
|
||||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
|
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override {
|
||||||
return m_exceptionTranslatorRegistry;
|
return m_exceptionTranslatorRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // IMutableRegistryHub
|
public: // IMutableRegistryHub
|
||||||
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) override {
|
||||||
m_reporterRegistry.registerReporter( name, factory );
|
m_reporterRegistry.registerReporter( name, factory );
|
||||||
}
|
}
|
||||||
virtual void registerTest( TestCase const& testInfo ) {
|
virtual void registerListener( Ptr<IReporterFactory> const& factory ) override {
|
||||||
|
m_reporterRegistry.registerListener( factory );
|
||||||
|
}
|
||||||
|
virtual void registerTest( TestCase const& testInfo ) override {
|
||||||
m_testCaseRegistry.registerTest( testInfo );
|
m_testCaseRegistry.registerTest( testInfo );
|
||||||
}
|
}
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) {
|
virtual void registerTranslator( const IExceptionTranslator* translator ) override {
|
||||||
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class ReporterRegistrar {
|
class ReporterRegistrar {
|
||||||
|
|
||||||
class ReporterFactory : public IReporterFactory {
|
class ReporterFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
// *** Please Note ***:
|
// *** Please Note ***:
|
||||||
// - If you end up here looking at a compiler error because it's trying to register
|
// - If you end up here looking at a compiler error because it's trying to register
|
||||||
@ -64,11 +64,35 @@ namespace Catch {
|
|||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class ListenerRegistrar {
|
||||||
|
|
||||||
|
class ListenerFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
|
return new T( config );
|
||||||
|
}
|
||||||
|
virtual std::string getDescription() const {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ListenerRegistrar() {
|
||||||
|
getMutableRegistryHub().registerListener( new ListenerFactory() );
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
||||||
namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
||||||
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||||
|
|
||||||
|
#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
|
||||||
|
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||||
|
@ -18,27 +18,32 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~ReporterRegistry() {
|
virtual ~ReporterRegistry() override {}
|
||||||
deleteAllValues( m_factories );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const override {
|
||||||
FactoryMap::const_iterator it = m_factories.find( name );
|
FactoryMap::const_iterator it = m_factories.find( name );
|
||||||
if( it == m_factories.end() )
|
if( it == m_factories.end() )
|
||||||
return CATCH_NULL;
|
return CATCH_NULL;
|
||||||
return it->second->create( ReporterConfig( config ) );
|
return it->second->create( ReporterConfig( config ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) {
|
||||||
m_factories.insert( std::make_pair( name, factory ) );
|
m_factories.insert( std::make_pair( name, factory ) );
|
||||||
}
|
}
|
||||||
|
void registerListener( Ptr<IReporterFactory> const& factory ) {
|
||||||
|
m_listeners.push_back( factory );
|
||||||
|
}
|
||||||
|
|
||||||
FactoryMap const& getFactories() const {
|
virtual FactoryMap const& getFactories() const override {
|
||||||
return m_factories;
|
return m_factories;
|
||||||
}
|
}
|
||||||
|
virtual Listeners const& getListeners() const override {
|
||||||
|
return m_listeners;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FactoryMap m_factories;
|
FactoryMap m_factories;
|
||||||
|
Listeners m_listeners;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# ifdef __ICC // icpc defines the __clang__ macro
|
# ifdef __ICC // icpc defines the __clang__ macro
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
@ -29,5 +26,3 @@
|
|||||||
# pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
# pragma GCC diagnostic ignored "-Wpadded"
|
# pragma GCC diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
|
@ -19,42 +19,48 @@ namespace Catch {
|
|||||||
StreamingReporterBase( ReporterConfig const& _config )
|
StreamingReporterBase( ReporterConfig const& _config )
|
||||||
: m_config( _config.fullConfig() ),
|
: m_config( _config.fullConfig() ),
|
||||||
stream( _config.stream() )
|
stream( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~StreamingReporterBase();
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& ) {}
|
virtual ~StreamingReporterBase() CATCH_OVERRIDE;
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) {
|
virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
|
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE {
|
||||||
currentTestRunInfo = _testRunInfo;
|
currentTestRunInfo = _testRunInfo;
|
||||||
}
|
}
|
||||||
virtual void testGroupStarting( GroupInfo const& _groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE {
|
||||||
currentGroupInfo = _groupInfo;
|
currentGroupInfo = _groupInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo = _testInfo;
|
currentTestCaseInfo = _testInfo;
|
||||||
}
|
}
|
||||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_sectionStack.push_back( _sectionInfo );
|
m_sectionStack.push_back( _sectionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) {
|
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE {
|
||||||
m_sectionStack.pop_back();
|
m_sectionStack.pop_back();
|
||||||
}
|
}
|
||||||
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) {
|
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo.reset();
|
currentTestCaseInfo.reset();
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) {
|
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE {
|
||||||
currentGroupInfo.reset();
|
currentGroupInfo.reset();
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) {
|
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo.reset();
|
currentTestCaseInfo.reset();
|
||||||
currentGroupInfo.reset();
|
currentGroupInfo.reset();
|
||||||
currentTestRunInfo.reset();
|
currentTestRunInfo.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) {
|
virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {
|
||||||
// Don't do anything with this by default.
|
// Don't do anything with this by default.
|
||||||
// It can optionally be overridden in the derived class.
|
// It can optionally be overridden in the derived class.
|
||||||
}
|
}
|
||||||
@ -67,6 +73,7 @@ namespace Catch {
|
|||||||
LazyStat<TestCaseInfo> currentTestCaseInfo;
|
LazyStat<TestCaseInfo> currentTestCaseInfo;
|
||||||
|
|
||||||
std::vector<SectionInfo> m_sectionStack;
|
std::vector<SectionInfo> m_sectionStack;
|
||||||
|
ReporterPreferences m_reporterPrefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
|
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
|
||||||
@ -118,15 +125,21 @@ namespace Catch {
|
|||||||
CumulativeReporterBase( ReporterConfig const& _config )
|
CumulativeReporterBase( ReporterConfig const& _config )
|
||||||
: m_config( _config.fullConfig() ),
|
: m_config( _config.fullConfig() ),
|
||||||
stream( _config.stream() )
|
stream( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
~CumulativeReporterBase();
|
~CumulativeReporterBase();
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& ) {}
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
virtual void testGroupStarting( GroupInfo const& ) {}
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& ) {}
|
virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
|
SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
|
||||||
Ptr<SectionNode> node;
|
Ptr<SectionNode> node;
|
||||||
if( m_sectionStack.empty() ) {
|
if( m_sectionStack.empty() ) {
|
||||||
@ -151,7 +164,7 @@ namespace Catch {
|
|||||||
m_deepestSection = node;
|
m_deepestSection = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {}
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
||||||
assert( !m_sectionStack.empty() );
|
assert( !m_sectionStack.empty() );
|
||||||
@ -159,13 +172,13 @@ namespace Catch {
|
|||||||
sectionNode.assertions.push_back( assertionStats );
|
sectionNode.assertions.push_back( assertionStats );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) {
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
||||||
assert( !m_sectionStack.empty() );
|
assert( !m_sectionStack.empty() );
|
||||||
SectionNode& node = *m_sectionStack.back();
|
SectionNode& node = *m_sectionStack.back();
|
||||||
node.stats = sectionStats;
|
node.stats = sectionStats;
|
||||||
m_sectionStack.pop_back();
|
m_sectionStack.pop_back();
|
||||||
}
|
}
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
|
Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
|
||||||
assert( m_sectionStack.size() == 0 );
|
assert( m_sectionStack.size() == 0 );
|
||||||
node->children.push_back( m_rootSection );
|
node->children.push_back( m_rootSection );
|
||||||
@ -176,12 +189,12 @@ namespace Catch {
|
|||||||
m_deepestSection->stdOut = testCaseStats.stdOut;
|
m_deepestSection->stdOut = testCaseStats.stdOut;
|
||||||
m_deepestSection->stdErr = testCaseStats.stdErr;
|
m_deepestSection->stdErr = testCaseStats.stdErr;
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
|
Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
|
||||||
node->children.swap( m_testCases );
|
node->children.swap( m_testCases );
|
||||||
m_testGroups.push_back( node );
|
m_testGroups.push_back( node );
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestRunNode> node = new TestRunNode( testRunStats );
|
Ptr<TestRunNode> node = new TestRunNode( testRunStats );
|
||||||
node->children.swap( m_testGroups );
|
node->children.swap( m_testGroups );
|
||||||
m_testRuns.push_back( node );
|
m_testRuns.push_back( node );
|
||||||
@ -189,7 +202,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
virtual void testRunEndedCumulative() = 0;
|
virtual void testRunEndedCumulative() = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) {}
|
virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
Ptr<IConfig> m_config;
|
Ptr<IConfig> m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
@ -203,6 +216,7 @@ namespace Catch {
|
|||||||
Ptr<SectionNode> m_rootSection;
|
Ptr<SectionNode> m_rootSection;
|
||||||
Ptr<SectionNode> m_deepestSection;
|
Ptr<SectionNode> m_deepestSection;
|
||||||
std::vector<Ptr<SectionNode> > m_sectionStack;
|
std::vector<Ptr<SectionNode> > m_sectionStack;
|
||||||
|
ReporterPreferences m_reporterPrefs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,6 +230,18 @@ namespace Catch {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct TestEventListenerBase : StreamingReporterBase {
|
||||||
|
TestEventListenerBase( ReporterConfig const& _config )
|
||||||
|
: StreamingReporterBase( _config )
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||||
|
@ -21,24 +21,19 @@ namespace Catch {
|
|||||||
m_headerPrinted( false )
|
m_headerPrinted( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~ConsoleReporter();
|
virtual ~ConsoleReporter() CATCH_OVERRIDE;
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as plain lines of text";
|
return "Reports test results as plain lines of text";
|
||||||
}
|
}
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = false;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& spec ) {
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
||||||
stream << "No test cases matched '" << spec << "'" << std::endl;
|
stream << "No test cases matched '" << spec << "'" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
|
||||||
AssertionResult const& result = _assertionStats.assertionResult;
|
AssertionResult const& result = _assertionStats.assertionResult;
|
||||||
|
|
||||||
bool printInfoMessages = true;
|
bool printInfoMessages = true;
|
||||||
@ -58,11 +53,11 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
StreamingReporterBase::sectionStarting( _sectionInfo );
|
StreamingReporterBase::sectionStarting( _sectionInfo );
|
||||||
}
|
}
|
||||||
virtual void sectionEnded( SectionStats const& _sectionStats ) {
|
virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE {
|
||||||
if( _sectionStats.missingAssertions ) {
|
if( _sectionStats.missingAssertions ) {
|
||||||
lazyPrint();
|
lazyPrint();
|
||||||
Colour colour( Colour::ResultError );
|
Colour colour( Colour::ResultError );
|
||||||
@ -84,11 +79,11 @@ namespace Catch {
|
|||||||
StreamingReporterBase::sectionEnded( _sectionStats );
|
StreamingReporterBase::sectionEnded( _sectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE {
|
||||||
if( currentGroupInfo.used ) {
|
if( currentGroupInfo.used ) {
|
||||||
printSummaryDivider();
|
printSummaryDivider();
|
||||||
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
||||||
@ -97,7 +92,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE {
|
||||||
printTotalsDivider( _testRunStats.totals );
|
printTotalsDivider( _testRunStats.totals );
|
||||||
printTotals( _testRunStats.totals );
|
printTotals( _testRunStats.totals );
|
||||||
stream << std::endl;
|
stream << std::endl;
|
||||||
|
@ -23,28 +23,24 @@ namespace Catch {
|
|||||||
JunitReporter( ReporterConfig const& _config )
|
JunitReporter( ReporterConfig const& _config )
|
||||||
: CumulativeReporterBase( _config ),
|
: CumulativeReporterBase( _config ),
|
||||||
xml( _config.stream() )
|
xml( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
~JunitReporter();
|
virtual ~JunitReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results in an XML format that looks like Ant's junitreport target";
|
return "Reports test results in an XML format that looks like Ant's junitreport target";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& /*spec*/ ) {}
|
virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const {
|
virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE {
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& runInfo ) {
|
|
||||||
CumulativeReporterBase::testRunStarting( runInfo );
|
CumulativeReporterBase::testRunStarting( runInfo );
|
||||||
xml.startElement( "testsuites" );
|
xml.startElement( "testsuites" );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
suiteTimer.start();
|
suiteTimer.start();
|
||||||
stdOutForSuite.str("");
|
stdOutForSuite.str("");
|
||||||
stdErrForSuite.str("");
|
stdErrForSuite.str("");
|
||||||
@ -52,25 +48,25 @@ namespace Catch {
|
|||||||
CumulativeReporterBase::testGroupStarting( groupInfo );
|
CumulativeReporterBase::testGroupStarting( groupInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
|
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
|
||||||
unexpectedExceptions++;
|
unexpectedExceptions++;
|
||||||
return CumulativeReporterBase::assertionEnded( assertionStats );
|
return CumulativeReporterBase::assertionEnded( assertionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
stdOutForSuite << testCaseStats.stdOut;
|
stdOutForSuite << testCaseStats.stdOut;
|
||||||
stdErrForSuite << testCaseStats.stdErr;
|
stdErrForSuite << testCaseStats.stdErr;
|
||||||
CumulativeReporterBase::testCaseEnded( testCaseStats );
|
CumulativeReporterBase::testCaseEnded( testCaseStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
double suiteTime = suiteTimer.getElapsedSeconds();
|
double suiteTime = suiteTimer.getElapsedSeconds();
|
||||||
CumulativeReporterBase::testGroupEnded( testGroupStats );
|
CumulativeReporterBase::testGroupEnded( testGroupStats );
|
||||||
writeGroup( *m_testGroups.back(), suiteTime );
|
writeGroup( *m_testGroups.back(), suiteTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunEndedCumulative() {
|
virtual void testRunEndedCumulative() CATCH_OVERRIDE {
|
||||||
xml.endElement();
|
xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wpadded"
|
# pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@ -27,7 +29,9 @@ namespace Catch {
|
|||||||
TeamCityReporter( ReporterConfig const& _config )
|
TeamCityReporter( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config ),
|
: StreamingReporterBase( _config ),
|
||||||
m_headerPrintedForThisSection( false )
|
m_headerPrintedForThisSection( false )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string escape( std::string const& str ) {
|
static std::string escape( std::string const& str ) {
|
||||||
std::string escaped = str;
|
std::string escaped = str;
|
||||||
@ -39,18 +43,13 @@ namespace Catch {
|
|||||||
replaceInPlace( escaped, "]", "|]" );
|
replaceInPlace( escaped, "]", "|]" );
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
virtual ~TeamCityReporter();
|
virtual ~TeamCityReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as TeamCity service messages";
|
return "Reports test results as TeamCity service messages";
|
||||||
}
|
}
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) {
|
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
stream << "##teamcity[testIgnored name='"
|
stream << "##teamcity[testIgnored name='"
|
||||||
<< escape( testInfo.name ) << "'";
|
<< escape( testInfo.name ) << "'";
|
||||||
if( testInfo.isHidden() )
|
if( testInfo.isHidden() )
|
||||||
@ -60,24 +59,24 @@ namespace Catch {
|
|||||||
stream << "]\n";
|
stream << "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& /* spec */ ) {}
|
virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupStarting( groupInfo );
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
stream << "##teamcity[testSuiteStarted name='"
|
stream << "##teamcity[testSuiteStarted name='"
|
||||||
<< escape( groupInfo.name ) << "']\n";
|
<< escape( groupInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupEnded( testGroupStats );
|
StreamingReporterBase::testGroupEnded( testGroupStats );
|
||||||
stream << "##teamcity[testSuiteFinished name='"
|
stream << "##teamcity[testSuiteFinished name='"
|
||||||
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
AssertionResult const& result = assertionStats.assertionResult;
|
AssertionResult const& result = assertionStats.assertionResult;
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
|
|
||||||
@ -143,18 +142,18 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_headerPrintedForThisSection = false;
|
m_headerPrintedForThisSection = false;
|
||||||
StreamingReporterBase::sectionStarting( sectionInfo );
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting( testInfo );
|
StreamingReporterBase::testCaseStarting( testInfo );
|
||||||
stream << "##teamcity[testStarted name='"
|
stream << "##teamcity[testStarted name='"
|
||||||
<< escape( testInfo.name ) << "']\n";
|
<< escape( testInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( testCaseStats );
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
if( !testCaseStats.stdOut.empty() )
|
if( !testCaseStats.stdOut.empty() )
|
||||||
stream << "##teamcity[testStdOut name='"
|
stream << "##teamcity[testStdOut name='"
|
||||||
@ -216,7 +215,7 @@ namespace Catch {
|
|||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
# pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
|
||||||
|
@ -21,26 +21,23 @@ namespace Catch {
|
|||||||
XmlReporter( ReporterConfig const& _config )
|
XmlReporter( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config ),
|
: StreamingReporterBase( _config ),
|
||||||
m_sectionDepth( 0 )
|
m_sectionDepth( 0 )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~XmlReporter();
|
virtual ~XmlReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as an XML document";
|
return "Reports test results as an XML document";
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // StreamingReporterBase
|
public: // StreamingReporterBase
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& s ) {
|
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::noMatchingTestCases( s );
|
StreamingReporterBase::noMatchingTestCases( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& testInfo ) {
|
virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testRunStarting( testInfo );
|
StreamingReporterBase::testRunStarting( testInfo );
|
||||||
m_xml.setStream( stream );
|
m_xml.setStream( stream );
|
||||||
m_xml.startElement( "Catch" );
|
m_xml.startElement( "Catch" );
|
||||||
@ -48,13 +45,13 @@ namespace Catch {
|
|||||||
m_xml.writeAttribute( "name", m_config->name() );
|
m_xml.writeAttribute( "name", m_config->name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupStarting( groupInfo );
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
m_xml.startElement( "Group" )
|
m_xml.startElement( "Group" )
|
||||||
.writeAttribute( "name", groupInfo.name );
|
.writeAttribute( "name", groupInfo.name );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting(testInfo);
|
StreamingReporterBase::testCaseStarting(testInfo);
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
||||||
|
|
||||||
@ -62,7 +59,7 @@ namespace Catch {
|
|||||||
m_testCaseTimer.start();
|
m_testCaseTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::sectionStarting( sectionInfo );
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
if( m_sectionDepth++ > 0 ) {
|
if( m_sectionDepth++ > 0 ) {
|
||||||
m_xml.startElement( "Section" )
|
m_xml.startElement( "Section" )
|
||||||
@ -71,9 +68,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) { }
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
||||||
|
|
||||||
// Print any info messages in <Info> tags.
|
// Print any info messages in <Info> tags.
|
||||||
@ -144,7 +141,7 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) {
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::sectionEnded( sectionStats );
|
StreamingReporterBase::sectionEnded( sectionStats );
|
||||||
if( --m_sectionDepth > 0 ) {
|
if( --m_sectionDepth > 0 ) {
|
||||||
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
|
||||||
@ -159,7 +156,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( testCaseStats );
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
|
||||||
e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
|
e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
|
||||||
@ -170,7 +167,7 @@ namespace Catch {
|
|||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupEnded( testGroupStats );
|
StreamingReporterBase::testGroupEnded( testGroupStats );
|
||||||
// TODO: Check testGroupStats.aborting and act accordingly.
|
// TODO: Check testGroupStats.aborting and act accordingly.
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
@ -180,7 +177,7 @@ namespace Catch {
|
|||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testRunEnded( testRunStats );
|
StreamingReporterBase::testRunEnded( testRunStats );
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
.writeAttribute( "successes", testRunStats.totals.assertions.passed )
|
.writeAttribute( "successes", testRunStats.totals.assertions.passed )
|
||||||
|
@ -798,5 +798,5 @@ with expansion:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 159 | 119 passed | 39 failed | 1 failed as expected
|
test cases: 159 | 119 passed | 39 failed | 1 failed as expected
|
||||||
assertions: 784 | 691 passed | 80 failed | 13 failed as expected
|
assertions: 788 | 695 passed | 80 failed | 13 failed as expected
|
||||||
|
|
||||||
|
@ -3929,7 +3929,7 @@ with expansion:
|
|||||||
|
|
||||||
TestMain.cpp:<line number>:
|
TestMain.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK( config.reporterName.empty() )
|
CHECK( config.reporterNames.empty() )
|
||||||
with expansion:
|
with expansion:
|
||||||
true
|
true
|
||||||
|
|
||||||
@ -4019,7 +4019,7 @@ PASSED:
|
|||||||
|
|
||||||
TestMain.cpp:<line number>:
|
TestMain.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( config.reporterName == "console" )
|
REQUIRE( config.reporterNames[0] == "console" )
|
||||||
with expansion:
|
with expansion:
|
||||||
"console" == "console"
|
"console" == "console"
|
||||||
|
|
||||||
@ -4037,10 +4037,40 @@ PASSED:
|
|||||||
|
|
||||||
TestMain.cpp:<line number>:
|
TestMain.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( config.reporterName == "xml" )
|
REQUIRE( config.reporterNames[0] == "xml" )
|
||||||
with expansion:
|
with expansion:
|
||||||
"xml" == "xml"
|
"xml" == "xml"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Process can be configured on command line
|
||||||
|
reporter
|
||||||
|
-r xml and junit
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
TestMain.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
TestMain.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) )
|
||||||
|
|
||||||
|
TestMain.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( config.reporterNames.size() == 2 )
|
||||||
|
with expansion:
|
||||||
|
2 == 2
|
||||||
|
|
||||||
|
TestMain.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( config.reporterNames[0] == "xml" )
|
||||||
|
with expansion:
|
||||||
|
"xml" == "xml"
|
||||||
|
|
||||||
|
TestMain.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( config.reporterNames[1] == "junit" )
|
||||||
|
with expansion:
|
||||||
|
"junit" == "junit"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Process can be configured on command line
|
Process can be configured on command line
|
||||||
reporter
|
reporter
|
||||||
@ -4055,7 +4085,7 @@ PASSED:
|
|||||||
|
|
||||||
TestMain.cpp:<line number>:
|
TestMain.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( config.reporterName == "junit" )
|
REQUIRE( config.reporterNames[0] == "junit" )
|
||||||
with expansion:
|
with expansion:
|
||||||
"junit" == "junit"
|
"junit" == "junit"
|
||||||
|
|
||||||
@ -8141,5 +8171,5 @@ with expansion:
|
|||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 159 | 103 passed | 55 failed | 1 failed as expected
|
test cases: 159 | 103 passed | 55 failed | 1 failed as expected
|
||||||
assertions: 804 | 691 passed | 100 failed | 13 failed as expected
|
assertions: 808 | 695 passed | 100 failed | 13 failed as expected
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CatchSelfTest" errors="12" failures="88" tests="804" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="CatchSelfTest" errors="12" failures="88" tests="808" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||||
@ -478,6 +478,7 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="reporter/-r xml and junit" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
|
||||||
|
@ -4013,7 +4013,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="CHECK" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
config.reporterName.empty()
|
config.reporterNames.empty()
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
true
|
true
|
||||||
@ -4123,7 +4123,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
config.reporterName == "console"
|
config.reporterNames[0] == "console"
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"console" == "console"
|
"console" == "console"
|
||||||
@ -4145,7 +4145,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
config.reporterName == "xml"
|
config.reporterNames[0] == "xml"
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"xml" == "xml"
|
"xml" == "xml"
|
||||||
@ -4155,6 +4155,44 @@
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</Section>
|
||||||
|
<Section name="reporter">
|
||||||
|
<Section name="-r xml and junit">
|
||||||
|
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
|
<Original>
|
||||||
|
parseIntoConfig( argv, config )
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
parseIntoConfig( argv, config )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
|
<Original>
|
||||||
|
config.reporterNames.size() == 2
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
2 == 2
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
|
<Original>
|
||||||
|
config.reporterNames[0] == "xml"
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
"xml" == "xml"
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
|
<Original>
|
||||||
|
config.reporterNames[1] == "junit"
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
"junit" == "junit"
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
<Section name="reporter">
|
<Section name="reporter">
|
||||||
<Section name="--reporter/junit">
|
<Section name="--reporter/junit">
|
||||||
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
@ -4167,7 +4205,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
config.reporterName == "junit"
|
config.reporterNames[0] == "junit"
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
"junit" == "junit"
|
"junit" == "junit"
|
||||||
@ -8425,7 +8463,7 @@ there"
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="691" failures="100" expectedFailures="13"/>
|
<OverallResults successes="695" failures="100" expectedFailures="13"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="691" failures="100" expectedFailures="13"/>
|
<OverallResults successes="695" failures="100" expectedFailures="13"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -7,14 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "internal/catch_xmlwriter.hpp"
|
#include "internal/catch_xmlwriter.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
#include "catch_suppress_warnings.h"
|
||||||
#include "catch_interfaces_exception.h"
|
#include "catch_interfaces_exception.h"
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_suppress_warnings.h"
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user