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
|
|
|
|
{
|
|
|
|
class iTchRunnerReporter : public IReporter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
iTchRunnerReporter
|
|
|
|
(
|
|
|
|
id<iTchRunnerDelegate> delegate
|
|
|
|
)
|
2012-02-27 20:03:54 +01:00
|
|
|
: m_delegate( delegate )
|
2011-02-08 19:48:34 +01:00
|
|
|
{
|
|
|
|
}
|
2012-02-27 20:03:54 +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
|
|
|
|
{
|
2012-02-27 20:03:54 +01:00
|
|
|
return m_totals.assertions.passed;
|
2011-02-08 19:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
size_t getFailed
|
|
|
|
()
|
|
|
|
const
|
|
|
|
{
|
2012-02-27 20:03:54 +01:00
|
|
|
return m_totals.assertions.failed;
|
2011-02-08 19:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
void reset()
|
|
|
|
{
|
2012-02-27 20:03:54 +01:00
|
|
|
m_totals = Totals();
|
2011-02-08 19:48:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private: // IReporter
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
virtual void StartTesting
|
|
|
|
()
|
|
|
|
{}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
virtual void EndTesting
|
|
|
|
(
|
2012-02-27 20:03:54 +01:00
|
|
|
const Totals& totals
|
2011-02-08 19:48:34 +01:00
|
|
|
)
|
|
|
|
{
|
2012-02-27 20:03:54 +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& ){}
|
2012-02-27 20:03:54 +01:00
|
|
|
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 ){}
|
2012-02-27 20:03:54 +01:00
|
|
|
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:
|
2012-02-27 20:03:54 +01:00
|
|
|
Totals m_totals;
|
2011-02-08 19:48:34 +01:00
|
|
|
|
|
|
|
id<iTchRunnerDelegate> m_delegate;
|
|
|
|
};
|
|
|
|
}
|