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

116 lines
3.2 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.
*
*/
#ifndef TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED
#define TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED
2011-02-08 19:48:34 +01:00
#include "catch.hpp"
@protocol iTchRunnerDelegate
-(void) testWasRun: (const Catch::AssertionResult*) result;
2011-02-08 19:48:34 +01:00
@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";
}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
size_t getSucceeded
()
const
{
return m_totals.assertions.passed;
2011-02-08 19:48:34 +01:00
}
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
}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
void reset()
{
m_totals = Totals();
2011-02-08 19:48:34 +01:00
}
2011-02-08 19:48:34 +01:00
private: // IReporter
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
virtual void StartTesting
()
{}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
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
}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
virtual void Result
(
const AssertionResult& result
2011-02-08 19:48:34 +01:00
)
{
[m_delegate testWasRun: &result];
}
2011-02-08 19:48:34 +01:00
///////////////////////////////////////////////////////////////////////////
// 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& ){}
2012-08-06 21:17:23 +02: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 21:17:23 +02:00
virtual void Aborted() {}
virtual void NoAssertionsInSection( std::string const& sectionName ) {}
virtual void NoAssertionsInTestCase( std::string const& testName ) {}
2011-02-08 19:48:34 +01:00
private:
Totals m_totals;
2011-02-08 19:48:34 +01:00
id<iTchRunnerDelegate> m_delegate;
};
}
#endif // TWOBLUECUBES_ITCHRUNNERREPORTER_H_INCLUDED