Tweaked console reporter some more

This commit is contained in:
Phil Nash 2013-01-17 12:07:34 +00:00
parent 10e891767f
commit b588755a92
6 changed files with 1941 additions and 1361 deletions

2
README
View File

@ -1,4 +1,4 @@
CATCH v0.9 build 13 (integration branch) CATCH v0.9 build 14 (integration branch)
--------------------------------------------- ---------------------------------------------
CATCH is an automated test framework for C, C++ and Objective-C. CATCH is an automated test framework for C, C++ and Objective-C.

View File

@ -13,7 +13,7 @@
namespace Catch { namespace Catch {
// These numbers are maintained by a script // These numbers are maintained by a script
Version libraryVersion( 0, 9, 13, "integration" ); Version libraryVersion( 0, 9, 14, "integration" );
} }
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED

View File

@ -43,23 +43,25 @@ namespace Catch {
lazyPrint(); lazyPrint();
{
TextColour colour( TextColour::FileName );
stream << result.getSourceInfo() << ":\n";
}
ResultComponents components( result ); ResultComponents components( result );
bool endsWithNewLine = false; bool endsWithNewLine = false;
if( _assertionStats.totals.assertions.total() > 0 ) { if( _assertionStats.totals.assertions.total() > 0 ) {
printOriginalExpression( result );
printResultType( components ); printResultType( components );
printOriginalExpression( result );
// printResultType( components );
endsWithNewLine = printReconstructedExpression( result ); endsWithNewLine = printReconstructedExpression( result );
} }
endsWithNewLine |= printMessage( components ); endsWithNewLine |= printMessage( components );
if( !endsWithNewLine ) // if( !endsWithNewLine )
stream << "\n"; // stream << "\n";
printSourceInfo( result );
stream << std::endl; stream << std::endl;
} }
void printSourceInfo( AssertionResult const& _result ) {
TextColour colour( TextColour::FileName );
stream << _result.getSourceInfo() << "\n";
}
struct ResultComponents { struct ResultComponents {
ResultComponents( AssertionResult const& _result ) ResultComponents( AssertionResult const& _result )
@ -69,18 +71,18 @@ namespace Catch {
switch( _result.getResultType() ) { switch( _result.getResultType() ) {
case ResultWas::Ok: case ResultWas::Ok:
colour = TextColour::Success; colour = TextColour::Success;
passOrFail = "passed"; passOrFail = "PASSED";
if( _result.hasMessage() ) if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
break; break;
case ResultWas::ExpressionFailed: case ResultWas::ExpressionFailed:
if( _result.isOk() ) { if( _result.isOk() ) {
colour = TextColour::Success; colour = TextColour::Success;
passOrFail = "failed - but was ok"; passOrFail = "FAILED - but was ok";
} }
else { else {
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
} }
if( _result.hasMessage() ){ if( _result.hasMessage() ){
messageLabel = "with message"; messageLabel = "with message";
@ -88,12 +90,12 @@ namespace Catch {
break; break;
case ResultWas::ThrewException: case ResultWas::ThrewException:
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
messageLabel = "due to unexpected exception with message"; messageLabel = "due to unexpected exception with message";
break; break;
case ResultWas::DidntThrowException: case ResultWas::DidntThrowException:
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
messageLabel = "because no exception was thrown where one was expected"; messageLabel = "because no exception was thrown where one was expected";
break; break;
case ResultWas::Info: case ResultWas::Info:
@ -103,12 +105,12 @@ namespace Catch {
messageLabel = "warning"; messageLabel = "warning";
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
passOrFail = "failed"; passOrFail = "FAILED";
colour = TextColour::Error; colour = TextColour::Error;
messageLabel = "explicitly with message"; messageLabel = "explicitly with message";
break; break;
case ResultWas::Exception: case ResultWas::Exception:
passOrFail = "failed"; passOrFail = "FAILED";
colour = TextColour::Error; colour = TextColour::Error;
if( _result.hasMessage() ) if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
@ -132,7 +134,7 @@ namespace Catch {
void printResultType( ResultComponents const& _components ) { void printResultType( ResultComponents const& _components ) {
if( !_components.passOrFail.empty() ) { if( !_components.passOrFail.empty() ) {
TextColour colour( _components.colour ); TextColour colour( _components.colour );
stream << _components.passOrFail << " "; stream << _components.passOrFail << ":\n";
} }
} }
bool printOriginalExpression( AssertionResult const& _result ) { bool printOriginalExpression( AssertionResult const& _result ) {

File diff suppressed because it is too large Load Diff

View File

@ -15,8 +15,8 @@
// !TBD: story scenarios map to class based tests // !TBD: story scenarios map to class based tests
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define GIVEN( desc ) SECTION( " Given: " desc, "" ) #define GIVEN( desc ) SECTION( " Given: " desc, "" )
#define WHEN( desc ) SECTION( " When: " desc, "" ) #define WHEN( desc ) SECTION( " When: " desc, "" )
#define THEN( desc ) SECTION( " Then: " desc, "" ) #define THEN( desc ) SECTION( " Then: " desc, "" )
inline bool itDoesThis(){ return true; } inline bool itDoesThis(){ return true; }

View File

@ -1,6 +1,6 @@
/* /*
* CATCH v0.9 build 13 (integration branch) * CATCH v0.9 build 14 (integration branch)
* Generated: 2013-01-16 09:43:42.849422 * Generated: 2013-01-17 12:06:33.338396
* ---------------------------------------------------------- * ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly * This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
@ -5777,7 +5777,7 @@ namespace Catch {
namespace Catch { namespace Catch {
// These numbers are maintained by a script // These numbers are maintained by a script
Version libraryVersion( 0, 9, 13, "integration" ); Version libraryVersion( 0, 9, 14, "integration" );
} }
// #included from: catch_line_wrap.hpp // #included from: catch_line_wrap.hpp
@ -6845,23 +6845,25 @@ namespace Catch {
lazyPrint(); lazyPrint();
{
TextColour colour( TextColour::FileName );
stream << result.getSourceInfo() << ":\n";
}
ResultComponents components( result ); ResultComponents components( result );
bool endsWithNewLine = false; bool endsWithNewLine = false;
if( _assertionStats.totals.assertions.total() > 0 ) { if( _assertionStats.totals.assertions.total() > 0 ) {
printOriginalExpression( result );
printResultType( components ); printResultType( components );
printOriginalExpression( result );
// printResultType( components );
endsWithNewLine = printReconstructedExpression( result ); endsWithNewLine = printReconstructedExpression( result );
} }
endsWithNewLine |= printMessage( components ); endsWithNewLine |= printMessage( components );
if( !endsWithNewLine ) // if( !endsWithNewLine )
stream << "\n"; // stream << "\n";
printSourceInfo( result );
stream << std::endl; stream << std::endl;
} }
void printSourceInfo( AssertionResult const& _result ) {
TextColour colour( TextColour::FileName );
stream << _result.getSourceInfo() << "\n";
}
struct ResultComponents { struct ResultComponents {
ResultComponents( AssertionResult const& _result ) ResultComponents( AssertionResult const& _result )
@ -6871,18 +6873,18 @@ namespace Catch {
switch( _result.getResultType() ) { switch( _result.getResultType() ) {
case ResultWas::Ok: case ResultWas::Ok:
colour = TextColour::Success; colour = TextColour::Success;
passOrFail = "passed"; passOrFail = "PASSED";
if( _result.hasMessage() ) if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
break; break;
case ResultWas::ExpressionFailed: case ResultWas::ExpressionFailed:
if( _result.isOk() ) { if( _result.isOk() ) {
colour = TextColour::Success; colour = TextColour::Success;
passOrFail = "failed - but was ok"; passOrFail = "FAILED - but was ok";
} }
else { else {
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
} }
if( _result.hasMessage() ){ if( _result.hasMessage() ){
messageLabel = "with message"; messageLabel = "with message";
@ -6890,12 +6892,12 @@ namespace Catch {
break; break;
case ResultWas::ThrewException: case ResultWas::ThrewException:
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
messageLabel = "due to unexpected exception with message"; messageLabel = "due to unexpected exception with message";
break; break;
case ResultWas::DidntThrowException: case ResultWas::DidntThrowException:
colour = TextColour::Error; colour = TextColour::Error;
passOrFail = "failed"; passOrFail = "FAILED";
messageLabel = "because no exception was thrown where one was expected"; messageLabel = "because no exception was thrown where one was expected";
break; break;
case ResultWas::Info: case ResultWas::Info:
@ -6905,12 +6907,12 @@ namespace Catch {
messageLabel = "warning"; messageLabel = "warning";
break; break;
case ResultWas::ExplicitFailure: case ResultWas::ExplicitFailure:
passOrFail = "failed"; passOrFail = "FAILED";
colour = TextColour::Error; colour = TextColour::Error;
messageLabel = "explicitly with message"; messageLabel = "explicitly with message";
break; break;
case ResultWas::Exception: case ResultWas::Exception:
passOrFail = "failed"; passOrFail = "FAILED";
colour = TextColour::Error; colour = TextColour::Error;
if( _result.hasMessage() ) if( _result.hasMessage() )
messageLabel = "with message"; messageLabel = "with message";
@ -6934,7 +6936,7 @@ namespace Catch {
void printResultType( ResultComponents const& _components ) { void printResultType( ResultComponents const& _components ) {
if( !_components.passOrFail.empty() ) { if( !_components.passOrFail.empty() ) {
TextColour colour( _components.colour ); TextColour colour( _components.colour );
stream << _components.passOrFail << " "; stream << _components.passOrFail << ":\n";
} }
} }
bool printOriginalExpression( AssertionResult const& _result ) { bool printOriginalExpression( AssertionResult const& _result ) {
@ -7040,13 +7042,13 @@ namespace Catch {
} }
void lazyPrintGroupInfo() { void lazyPrintGroupInfo() {
if( !unusedGroupInfo->name.empty() && unusedGroupInfo->groupsCounts > 1 ) { if( !unusedGroupInfo->name.empty() && unusedGroupInfo->groupsCounts > 1 ) {
printHeader( "Group", unusedGroupInfo->name ); printHeader( "Group: " + unusedGroupInfo->name );
unusedGroupInfo.reset(); unusedGroupInfo.reset();
} }
} }
void lazyPrintTestCaseInfo() { void lazyPrintTestCaseInfo() {
if( !currentSectionInfo ) { if( !currentSectionInfo ) {
printTestCaseHeader(); printHeader( unusedTestCaseInfo->name );
stream << std::endl; stream << std::endl;
unusedTestCaseInfo.reset(); unusedTestCaseInfo.reset();
} }
@ -7061,38 +7063,21 @@ namespace Catch {
// Sections // Sections
if( !sections.empty() ) { if( !sections.empty() ) {
printTestCaseHeader(); printHeader( unusedTestCaseInfo->name, false );
std::string firstInset;
std::string inset;
if( sections.size() > 1 ) {
firstInset = "Sections: ";
inset = " ";
}
else {
firstInset = "Section: ";
inset = " ";
}
typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It; typedef std::vector<ThreadedSectionInfo*>::const_reverse_iterator It;
for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it ) { for( It it = sections.rbegin(), itEnd = sections.rend(); it != itEnd; ++it )
if( it == sections.rbegin() ) stream << " " << (*it)->name << "\n";
stream << firstInset;
else
stream << inset;
stream << (*it)->name << "\n";
}
stream << getDashes() << "\n" << std::endl; stream << getDashes() << "\n" << std::endl;
unusedSectionInfo.reset(); unusedSectionInfo.reset();
} }
} }
void printTestCaseHeader() { void printHeader( std::string const& _name, bool closed = true ) {
printHeader( "Test case", unusedTestCaseInfo->name );
}
void printHeader( std::string const& _type, std::string const& _name ) {
stream << getDashes() << "\n" stream << getDashes() << "\n"
<< _type << ": '" << _name << "'\n" << _name << "\n";
<< getDashes() << "\n"; if( closed )
stream << getDashes() << "\n";
} }
void printTotals( const Totals& totals ) { void printTotals( const Totals& totals ) {
@ -7150,12 +7135,12 @@ namespace Catch {
} }
static std::string const& getDashes() { static std::string const& getDashes() {
static const std::string dashes static const std::string dashes
= "----------------------------------------------------------------"; = "-----------------------------------------------------------------";
return dashes; return dashes;
} }
static std::string const& getDoubleDashes() { static std::string const& getDoubleDashes() {
static const std::string doubleDashes static const std::string doubleDashes
= "================================================================"; = "=================================================================";
return doubleDashes; return doubleDashes;
} }