console reporter:

Always print test case + sections in header for every new section.
Group sections into single block
Tweaked BDD mappings to print out nicely with above
This commit is contained in:
Phil Nash 2013-01-15 23:14:52 +00:00
parent 097282e00e
commit f8ba2277d3
4 changed files with 411 additions and 279 deletions

View File

@ -79,14 +79,12 @@ namespace Catch
struct ThreadedSectionInfo : SectionInfo, SharedImpl<> {
ThreadedSectionInfo( SectionInfo const& _sectionInfo, Ptr<ThreadedSectionInfo> const& _parent = Ptr<ThreadedSectionInfo>() )
: SectionInfo( _sectionInfo ),
parent( _parent ),
printed( false )
parent( _parent )
{}
virtual ~ThreadedSectionInfo();
std::vector<Ptr<ThreadedSectionInfo> > children;
Ptr<ThreadedSectionInfo> parent;
bool printed;
};
struct AssertionStats {

View File

@ -213,7 +213,7 @@ namespace Catch {
void lazyPrint() {
bool needsNewline = unusedTestCaseInfo || ( currentSectionInfo && !currentSectionInfo->printed );
bool needsNewline = unusedTestCaseInfo || currentSectionInfo;
if( testRunInfo )
lazyPrintRunInfo();
@ -221,7 +221,7 @@ namespace Catch {
lazyPrintGroupInfo();
if( unusedTestCaseInfo )
lazyPrintTestCaseInfo();
if( currentSectionInfo && !currentSectionInfo->printed )
if( currentSectionInfo)
lazyPrintSectionInfo();
if( needsNewline )
stream << "\n";
@ -285,7 +285,6 @@ namespace Catch {
else
stream << inset;
stream << (*it)->name << "\n";
// (*it)->printed = true; // !TBD remove flag?
}
stream << getDashes() << std::endl;
unusedSectionInfo.reset();

File diff suppressed because it is too large Load Diff

View File

@ -12,31 +12,22 @@
#include "catch.hpp"
#define STORY( a, b )
#define SCENARIO( storyName, desc ) TEST_CASE( desc, "" )
#define GIVEN( desc ) SECTION( desc, "" )
#define WHEN( desc ) SECTION( desc, "" )
#define THEN( desc ) SECTION( desc, "" )
// !TBD: story scenarios map to class based tests
#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags )
#define GIVEN( desc ) SECTION( "Given: " desc, "" )
#define WHEN( desc ) SECTION( "When: " desc, "" )
#define THEN( desc ) SECTION( "Then: " desc, "" )
inline bool itDoesThis(){ return true; }
STORY( storyName, "once upon a time" )
SCENARIO( storyName, "scenario name" )
{
GIVEN( "This stuff exists" )
{
SCENARIO( "Do that thing with the thing", "[tags]" ) {
GIVEN( "This stuff exists" ) {
// make stuff exist
WHEN( "I do this" )
{
WHEN( "I do this" ) {
// do this
THEN( "it should do this")
{
REQUIRE( itDoesThis() );
}
}
}
}