Fixed iOS test runner after reporter changes

This commit is contained in:
Phil Nash 2012-02-27 19:03:54 +00:00
parent 20df8c5da1
commit e1f1c6ca7e
3 changed files with 23 additions and 21 deletions

View File

@ -49,7 +49,7 @@ namespace Catch
{ {
ConsoleColourImpl() ConsoleColourImpl()
: hStdout( GetStdHandle(STD_OUTPUT_HANDLE) ), : hStdout( GetStdHandle(STD_OUTPUT_HANDLE) ),
wOldColorAttrs( 0 ) wOldColorAttrs( 0 )
{ {
GetConsoleScreenBufferInfo( hStdout, &csbiInfo ); GetConsoleScreenBufferInfo( hStdout, &csbiInfo );
wOldColorAttrs = csbiInfo.wAttributes; wOldColorAttrs = csbiInfo.wAttributes;

View File

@ -80,17 +80,17 @@
config.getReporter()->StartGroup( "" ); config.getReporter()->StartGroup( "" );
runner.runAll( true ); runner.runAll( true );
config.getReporter()->EndGroup( "", runner.getSuccessCount(), runner.getFailureCount() ); config.getReporter()->EndGroup( "", runner.getTotals() );
if( runner.getFailureCount() == 0 ) if( runner.getTotals().assertions.failed == 0 )
{ {
NSLog( @"no failures" ); NSLog( @"no failures" );
if( runner.getSuccessCount() > 0 ) if( runner.getTotals().assertions.passed > 0 )
appName.textColor = [[UIColor alloc] initWithRed:0.35 green:1 blue:0.35 alpha:1]; appName.textColor = [[UIColor alloc] initWithRed:0.35 green:1 blue:0.35 alpha:1];
} }
else else
{ {
NSLog( @"%lu failures", runner.getFailureCount() ); NSLog( @"%lu failures", runner.getTotals().assertions.failed );
appName.textColor = [[UIColor alloc] initWithRed:1 green:0.35 blue:0.35 alpha:1]; appName.textColor = [[UIColor alloc] initWithRed:1 green:0.35 blue:0.35 alpha:1];
} }
} }

View File

@ -24,11 +24,17 @@ namespace Catch
( (
id<iTchRunnerDelegate> delegate id<iTchRunnerDelegate> delegate
) )
: m_succeeded( 0 ), : m_delegate( delegate )
m_failed( 0 ),
m_delegate( delegate )
{ {
} }
///////////////////////////////////////////////////////////////////////////
virtual bool shouldRedirectStdout
()
const
{
return true;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
static std::string getDescription static std::string getDescription
@ -42,7 +48,7 @@ namespace Catch
() ()
const const
{ {
return m_succeeded; return m_totals.assertions.passed;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -50,14 +56,13 @@ namespace Catch
() ()
const const
{ {
return m_failed; return m_totals.assertions.failed;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void reset() void reset()
{ {
m_succeeded = 0; m_totals = Totals();
m_failed = 0;
} }
private: // IReporter private: // IReporter
@ -70,12 +75,10 @@ namespace Catch
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
virtual void EndTesting virtual void EndTesting
( (
std::size_t succeeded, const Totals& totals
std::size_t failed
) )
{ {
m_succeeded = succeeded; m_totals = totals;
m_failed = failed;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -90,15 +93,14 @@ namespace Catch
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Deliberately unimplemented: // Deliberately unimplemented:
virtual void StartGroup( const std::string& ){} virtual void StartGroup( const std::string& ){}
virtual void EndGroup( const std::string&, std::size_t, std::size_t ){} virtual void EndGroup( const std::string&, const Totals& ){}
virtual void StartTestCase( const TestCaseInfo& ){} virtual void StartTestCase( const TestCaseInfo& ){}
virtual void StartSection( const std::string&, const std::string ){} virtual void StartSection( const std::string&, const std::string ){}
virtual void EndSection( const std::string&, std::size_t, std::size_t ){} virtual void EndSection( const std::string&, const Counts& ){}
virtual void EndTestCase( const TestCaseInfo&, std::size_t, std::size_t, const std::string&, const std::string& ){} virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
private: private:
size_t m_succeeded; Totals m_totals;
size_t m_failed;
id<iTchRunnerDelegate> m_delegate; id<iTchRunnerDelegate> m_delegate;
}; };