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

108 lines
2.9 KiB
C
Raw Normal View History

2011-02-08 19:48:34 +01: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 09:16:30 +02:00
class iTchRunnerReporter : public SharedImpl<IReporter>
2011-02-08 19:48:34 +01:00
{
public:
///////////////////////////////////////////////////////////////////////////
iTchRunnerReporter
(
id<iTchRunnerDelegate> delegate
)
: m_delegate( delegate )
2011-02-08 19:48:34 +01:00
{
}
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
static std::string getDescription
()
{
return "Captures results for iOS runner";
}
///////////////////////////////////////////////////////////////////////////
size_t getSucceeded
()
const
{
return m_totals.assertions.passed;
2011-02-08 19:48:34 +01:00
}
///////////////////////////////////////////////////////////////////////////
size_t getFailed
()
const
{
return m_totals.assertions.failed;
2011-02-08 19:48:34 +01:00
}
///////////////////////////////////////////////////////////////////////////
void reset()
{
m_totals = Totals();
2011-02-08 19:48:34 +01:00
}
private: // IReporter
///////////////////////////////////////////////////////////////////////////
virtual void StartTesting
()
{}
///////////////////////////////////////////////////////////////////////////
virtual void EndTesting
(
const Totals& totals
2011-02-08 19:48:34 +01:00
)
{
m_totals = totals;
2011-02-08 19:48:34 +01: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 19:48:34 +01:00
virtual void StartTestCase( const TestCaseInfo& ){}
virtual void StartSection( const std::string&, const std::string ){}
virtual void EndSection( const std::string&, const Counts& ){}
virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
2011-02-08 19:48:34 +01:00
private:
Totals m_totals;
2011-02-08 19:48:34 +01:00
id<iTchRunnerDelegate> m_delegate;
};
}