Catch/projects/runners/iTchRunner/internal/iTchRunnerReporter.h

109 lines
2.9 KiB
C
Raw Normal View History

2011-02-08 13:48:34 -05:00
/*
* iTchRunnerReporter.h
* iTchRunner
*
* Created by Phil on 07/02/2011.
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
*
*/
#include "catch.hpp"
@protocol iTchRunnerDelegate
-(void) testWasRun: (const Catch::ResultInfo*) result;
@end
namespace Catch
{
2012-05-10 03:16:30 -04:00
class iTchRunnerReporter : public SharedImpl<IReporter>
2011-02-08 13:48:34 -05:00
{
public:
///////////////////////////////////////////////////////////////////////////
iTchRunnerReporter
(
id<iTchRunnerDelegate> delegate
)
: m_delegate( delegate )
2011-02-08 13:48:34 -05:00
{
}
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
2011-02-08 13:48:34 -05:00
///////////////////////////////////////////////////////////////////////////
static std::string getDescription
()
{
return "Captures results for iOS runner";
}
///////////////////////////////////////////////////////////////////////////
size_t getSucceeded
()
const
{
return m_totals.assertions.passed;
2011-02-08 13:48:34 -05:00
}
///////////////////////////////////////////////////////////////////////////
size_t getFailed
()
const
{
return m_totals.assertions.failed;
2011-02-08 13:48:34 -05:00
}
///////////////////////////////////////////////////////////////////////////
void reset()
{
m_totals = Totals();
2011-02-08 13:48:34 -05:00
}
private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual void StartTesting
()
{}
///////////////////////////////////////////////////////////////////////////
virtual void EndTesting
(
const Totals& totals
2011-02-08 13:48:34 -05:00
)
{
m_totals = totals;
2011-02-08 13:48:34 -05:00
}
///////////////////////////////////////////////////////////////////////////
virtual void Result
(
const ResultInfo& result
)
{
[m_delegate testWasRun: &result];
}
///////////////////////////////////////////////////////////////////////////
// Deliberately unimplemented:
virtual void StartGroup( const std::string& ){}
virtual void EndGroup( const std::string&, const Totals& ){}
2011-02-08 13:48:34 -05:00
virtual void StartTestCase( const TestCaseInfo& ){}
2012-08-06 15:17:23 -04:00
virtual void StartSection( const std::string& sectionName, const std::string& description ) {}
virtual void EndSection( const std::string&, const Counts& ){}
virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
2012-08-06 15:17:23 -04:00
virtual void Aborted() {}
2011-02-08 13:48:34 -05:00
private:
Totals m_totals;
2011-02-08 13:48:34 -05:00
id<iTchRunnerDelegate> m_delegate;
};
}