Minimal changes to get iTchRunner to work again

This commit is contained in:
Phil Nash 2012-12-06 18:39:08 +00:00
parent ff03cdf2b2
commit daedf8ff5f
4 changed files with 58 additions and 16 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ projects/VS2010/TestCatch/_UpgradeReport_Files/
projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj.filters
projects/VisualStudio/TestCatch/UpgradeLog.XML
UpgradeLog.XML
projects/XCode4/iOSTest/Build/Intermediates/PrecompiledHeaders

View File

@ -75,40 +75,78 @@
}
// This is a copy & paste from Catch::Runner2 to get us bootstrapped (this is due to all be
// replaced anyway)
inline Catch::Totals runTestsForGroup( Catch::Runner& context, const Catch::TestCaseFilters& filterGroup ) {
using namespace Catch;
Totals totals;
std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin();
std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end();
int testsRunForGroup = 0;
for(; it != itEnd; ++it ) {
if( filterGroup.shouldInclude( *it ) ) {
testsRunForGroup++;
if( context.aborting() )
break;
totals += context.runTest( *it );
}
}
if( testsRunForGroup == 0 )
std::cerr << "\n[No test cases matched with: " << filterGroup.getName() << "]" << std::endl;
return totals;
}
///////////////////////////////////////////////////////////////////////////////
-(void) actionSheet: (UIActionSheet*) sheet clickedButtonAtIndex: (NSInteger) index
{
Catch::Config config;
config.setReporter( new Catch::iTchRunnerReporter( self ) );
Catch::Runner runner( config );
Catch::IReporter* reporter = new Catch::iTchRunnerReporter( self );
Catch::LegacyReporterAdapter* reporterAdapter = new Catch::LegacyReporterAdapter( reporter, Catch::ReporterConfig( config.stream(), config.data() ) );
Catch::Runner runner( config, reporterAdapter );
config.getReporter()->StartGroup( "" );
runner.runAll( true );
config.getReporter()->EndGroup( "", runner.getTotals() );
if( runner.getTotals().assertions.failed == 0 )
std::vector<Catch::TestCaseFilters> filterGroups;
Catch::TestCaseFilters filterGroup( "" );
filterGroups.push_back( filterGroup );
Catch::Totals totals;
std::vector<Catch::TestCaseFilters>::const_iterator it = filterGroups.begin();
std::vector<Catch::TestCaseFilters>::const_iterator itEnd = filterGroups.end();
for(; it != itEnd && !runner.aborting(); ++it ) {
runner.testGroupStarting( it->getName() );
totals += runTestsForGroup( runner, *it );
runner.testGroupEnded( it->getName(), totals );
}
if( totals.assertions.failed == 0 )
{
NSLog( @"no failures" );
if( runner.getTotals().assertions.passed > 0 )
if( totals.assertions.passed > 0 )
appName.textColor = [[UIColor alloc] initWithRed:0.35 green:1 blue:0.35 alpha:1];
}
else
{
NSLog( @"%lu failures", runner.getTotals().assertions.failed );
NSLog( @"%lu failures", totals.assertions.failed );
appName.textColor = [[UIColor alloc] initWithRed:1 green:0.35 blue:0.35 alpha:1];
}
}
///////////////////////////////////////////////////////////////////////////////
-(void) testWasRun: (const Catch::ResultInfo*) pResultInfo
-(void) testWasRun: (const Catch::AssertionResult*) pResultInfo
{
const Catch::ResultInfo& resultInfo = *pResultInfo;
const Catch::AssertionResult& resultInfo = *pResultInfo;
std::ostringstream oss;
if( resultInfo.hasExpression() )
{
oss << resultInfo.getExpression();
if( resultInfo.ok() )
if( resultInfo.isOk() )
oss << " succeeded";
else
oss << " failed";

View File

@ -13,7 +13,7 @@
@protocol iTchRunnerDelegate
-(void) testWasRun: (const Catch::ResultInfo*) result;
-(void) testWasRun: (const Catch::AssertionResult*) result;
@end
@ -87,7 +87,7 @@ namespace Catch
///////////////////////////////////////////////////////////////////////////
virtual void Result
(
const ResultInfo& result
const AssertionResult& result
)
{
[m_delegate testWasRun: &result];
@ -102,6 +102,8 @@ namespace Catch
virtual void EndSection( const std::string&, const Counts& ){}
virtual void EndTestCase( const TestCaseInfo&, const Totals&, const std::string&, const std::string& ){}
virtual void Aborted() {}
virtual void NoAssertionsInSection( std::string const& sectionName ) {}
virtual void NoAssertionsInTestCase( std::string const& testName ) {}
private:
Totals m_totals;

View File

@ -6,6 +6,7 @@
// Copyright Two Blue Cubes Ltd 2011. All rights reserved.
//
#define CATCH_CONFIG_RUNNER
#include "catch.hpp"
#import "internal/iTchRunnerAppDelegate.h"