Added cutoff option to command line

Aborts testing after a certain number of assertion failures
This commit is contained in:
Phil Nash
2012-06-01 19:40:27 +01:00
parent 163088a11f
commit 19b2aa6187
14 changed files with 233 additions and 73 deletions

View File

@@ -98,29 +98,21 @@ TEST_CASE( "Sections/nested3", "nested SECTION tests" )
CHECK( runner.getLog() ==
"\\[tc] ./Sections/nested/a/b\n"
" \\[g] test case run\n"
" \\ [s] c\n"
" \\ [s] d (leaf)\n"
" / [s] d (leaf)\n"
" / [s] c\n"
" /[g] test case run\n"
" \\ [s] c\n"
" \\ [s] d (leaf)\n"
" / [s] d (leaf)\n"
" / [s] c\n"
" \\[g] test case run\n"
" \\ [s] c\n"
" \\ [s] e (leaf)\n"
" / [s] e (leaf)\n"
" / [s] c\n"
" /[g] test case run\n"
" \\ [s] c\n"
" \\ [s] e (leaf)\n"
" / [s] e (leaf)\n"
" / [s] c\n"
" \\[g] test case run\n"
" \\ [s] c\n"
" / [s] c\n"
" /[g] test case run\n"
" \\ [s] c\n"
" / [s] c\n"
" \\[g] test case run\n"
" \\ [s] f (leaf)\n"
" / [s] f (leaf)\n"
" /[g] test case run\n"
" \\ [s] f (leaf)\n"
" / [s] f (leaf)\n"
"/[tc] ./Sections/nested/a/b\n" );

View File

@@ -74,6 +74,7 @@ TEST_CASE( "selftest/parser", "" ) {
CHECK( config.getTestSpecs().empty() );
CHECK( config.shouldDebugBreak() == false );
CHECK( config.showHelp() == false );
CHECK( config.getCutoff() == -1 );
CHECK( dynamic_cast<Catch::BasicReporter*>( config.getReporter().get() ) );
}
@@ -200,4 +201,39 @@ TEST_CASE( "selftest/parser", "" ) {
REQUIRE_THAT( config.getMessage(), Contains( "not accept" ) );
}
}
SECTION( "cutoff", "" ) {
SECTION( "-c", "" ) {
const char* argv[] = { "test", "-c" };
Catch::Config config;
CHECK( parseIntoConfig( argv, config ) );
REQUIRE( config.getCutoff() == 1 );
}
SECTION( "-c/2", "" ) {
const char* argv[] = { "test", "-c", "2" };
Catch::Config config;
CHECK( parseIntoConfig( argv, config ) );
REQUIRE( config.getCutoff() == 2 );
}
SECTION( "-c/error", "cutoff only takes one argument" ) {
const char* argv[] = { "test", "-c", "1", "2" };
Catch::Config config;
CHECK( parseIntoConfig( argv, config ) == false );
REQUIRE_THAT( config.getMessage(), Contains( "accepts" ) );
}
}
SECTION( "combinations", "" ) {
SECTION( "-c -b", "" ) {
const char* argv[] = { "test", "-c", "-b" };
Catch::Config config;
CHECK( parseIntoConfig( argv, config ) );
REQUIRE( config.getCutoff() == 1 );
REQUIRE( config.shouldDebugBreak() );
}
}
}

View File

@@ -77,6 +77,8 @@ namespace Catch {
openLabel( recordTestCases, testInfo.getName() );
}
virtual void Aborted(){}
virtual void EndTestCase( const TestCaseInfo& testInfo,
const Totals&,
const std::string&,