Add abiiity to stop after n tests. Add ordered list of tests to check sw4

This commit is contained in:
Malcolm Noyes
2013-12-09 23:12:05 +00:00
parent 15cc1fc185
commit e8c32e819c
8 changed files with 274 additions and 64 deletions

View File

@@ -23,7 +23,7 @@ namespace MI1
// greedy instantiation (or whatever process it uses) eliminate all other
// references to the globalCount
TEST_CASE("message counting1","")
TEST_CASE("message counting1","[vs]")
{
if( Counter::g_haveCountedMessages > 0 ) {
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
@@ -42,7 +42,7 @@ int g_haveCountedMessagesLong = 0;
namespace MI1
{
TEST_CASE("long message counting1","")
TEST_CASE("long message counting1","[vs]")
{
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );

View File

@@ -22,7 +22,7 @@ namespace MI2
// greedy instantiation (or whatever process it uses) eliminate all other
// references to the globalCount
TEST_CASE("message counting2","")
TEST_CASE("message counting2","[vs]")
{
if( Counter::g_haveCountedMessages > 0 ) {
REQUIRE( Catch::MessageInfoCounter<unsigned int>::globalCount > 0 );
@@ -41,7 +41,7 @@ extern int g_haveCountedMessagesLong;
namespace MI2
{
TEST_CASE("long message counting2","")
TEST_CASE("long message counting2","[vs]")
{
if( LongCounter::g_haveCountedMessagesLong > 0 ) {
REQUIRE( Catch::MessageInfoCounter<long>::globalCount > 0 );

View File

@@ -12,6 +12,7 @@
namespace AllTestsRunner {
#ifdef OLD_RUNNER
class NullStreamingReporter : public Catch::SharedImpl<Catch::IStreamingReporter> {
public:
@@ -54,6 +55,23 @@ namespace AllTestsRunner {
Catch::Ptr<Catch::IStreamingReporter> m_reporter;
};
NullStreamingReporter::~NullStreamingReporter() {}
Catch::Totals EmbeddedRunner::runMatching( const std::string& rawTestSpec, std::size_t groupIndex, std::size_t groupsCount, const std::string& ) {
std::ostringstream oss;
Catch::Ptr<Catch::Config> config = new Catch::Config();
config->setStreamBuf( oss.rdbuf() );
Catch::Totals totals;
// Scoped because RunContext doesn't report EndTesting until its destructor
{
Catch::RunContext runner( config.get(), m_reporter.get() );
totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount );
}
return totals;
}
class MetaTestRunner {
public:
@@ -116,23 +134,6 @@ namespace AllTestsRunner {
std::size_t m_groupsCount;
};
NullStreamingReporter::~NullStreamingReporter() {}
Catch::Totals EmbeddedRunner::runMatching( const std::string& rawTestSpec, std::size_t groupIndex, std::size_t groupsCount, const std::string& ) {
std::ostringstream oss;
Catch::Ptr<Catch::Config> config = new Catch::Config();
config->setStreamBuf( oss.rdbuf() );
Catch::Totals totals;
// Scoped because RunContext doesn't report EndTesting until its destructor
{
Catch::RunContext runner( config.get(), m_reporter.get() );
totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount );
}
return totals;
}
TEST_CASE( "Run all failing and succeeding tests", "[vsall]" ) {
///////////////////////////////////////////////////////////////////////////
@@ -181,8 +182,66 @@ namespace AllTestsRunner {
}
}
// mstest /TestContainer:Debug\ManagedTestCatch.dll /category:"all"
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
CATCH_MAP_CATEGORY_TO_TAG(all, "[vsall]");
TEST_CASE( "Run all failing and succeeding tests", "[sw4][vs]" ) {
CatchOverrides::ConfigGuard cg;
Catch::ConfigData cd(cg.value().get());
cd.name = "Test sw4";
cd.abortAfter = 1;
cd.showSuccessfulTests = true;
cd.warnings = Catch::WarnAbout::NoAssertions;
cd.abortAfter = -1;
Catch::Ptr<Catch::Config> config(new Catch::Config(cd));
Catch::MSTestReporter* rep = new Catch::MSTestReporter(config.get());
Catch::RunContext tr(config.get(), rep);
std::string names[] = {"one","two","three"};
std::vector<std::string> stringNames(names, names + (sizeof(names)/sizeof(std::string)));
std::vector<Catch::TestCase> testCase = Catch::getRegistryHub().getTestCaseRegistry().getMatchingTestCases( "Some simple comparisons between doubles" );
//std::vector<Catch::TestCase> testCase = Catch::getRegistryHub().getTestCaseRegistry().getMatchingTestCases(name_desc.name);
if( testCase.empty() ) Assert::Fail(FAIL_STRING("No tests match"));
if( testCase.size() > 1 ) Assert::Fail(FAIL_STRING("More than one test with the same name"));
Catch::Totals totals = tr.runTest(*testCase.begin());
if( totals.assertions.failed > 0 ) {
INTERNAL_CATCH_TEST_THROW_FAILURE
}
/*for(std::vector<Catch::TestCase>::iterator it = tests.begin(); it != tests.end(); ++it )
{
Catch::Totals totals;
std::size_t groupIndex(0);
std::size_t groupsCount(0);
{
EmbeddedRunner runner;
std::string name = it->getTestCaseInfo().name;
totals = runner.runMatching( name, groupIndex, groupsCount );
}
}*/
}
#endif
// mstest /TestContainer:Debug\ManagedTestCatch.dll /category:"all"
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
CATCH_MAP_CATEGORY_TO_TAG(all, "~[vs]");
CATCH_CONFIG_SHOW_SUCCESS(true)
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
CATCH_MAP_CATEGORY_TO_TAG(allSucceeding, "~[vs]");
CATCH_CONFIG_SHOW_SUCCESS(true)
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
CATCH_CONFIG_ABORT_AFTER(4)
CATCH_INTERNAL_CONFIG_ADD_TEST("Some simple comparisons between doubles")
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with different epsilons")
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with floats")
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with ints")
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate comparisons with mixed numeric types")
CATCH_INTERNAL_CONFIG_ADD_TEST("Use a custom approx")
CATCH_INTERNAL_CONFIG_ADD_TEST("Approximate PI")
CATCH_INTERNAL_CONFIG_ADD_TEST("A METHOD_AS_TEST_CASE based test run that succeeds")
CATCH_INTERNAL_CONFIG_ADD_TEST("A METHOD_AS_TEST_CASE based test run that fails")
CATCH_INTERNAL_CONFIG_ADD_TEST("A TEST_CASE_METHOD based test run that succeeds")
CATCH_INTERNAL_CONFIG_ADD_TEST("A TEST_CASE_METHOD based test run that fails")
CATCH_INTERNAL_CONFIG_ADD_TEST("Equality checks that should succeed")
CATCH_INTERNAL_CONFIG_ADD_TEST("Equality checks that should fail]")
INTERNAL_CATCH_MAP_CATEGORY_TO_LIST(allSucceedingAborting);
#endif
}

View File

@@ -24,26 +24,26 @@ namespace VisualStudioTests
};
int UniqueTestsFixture::uniqueID = 0;
TEST_CASE("M00", "[m_off]")
TEST_CASE("M00", "[m_off][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(!show);
}
CATCH_CONFIG_SHOW_SUCCESS(true)
TEST_CASE("M01", "[m_on]")
TEST_CASE("M01", "[m_on][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(show);
}
TEST_CASE("M02", "[m_off]")
TEST_CASE("M02", "[m_off][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(!show);
}
TEST_CASE_METHOD(UniqueTestsFixture, "M10", "[m_off]")
TEST_CASE_METHOD(UniqueTestsFixture, "M10", "[m_off][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(!show);
@@ -52,7 +52,7 @@ namespace VisualStudioTests
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
CATCH_CONFIG_SHOW_SUCCESS(true)
TEST_CASE_METHOD(UniqueTestsFixture, "M11", "[m_on]")
TEST_CASE_METHOD(UniqueTestsFixture, "M11", "[m_on][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(show);
@@ -61,7 +61,7 @@ namespace VisualStudioTests
CATCH_CONFIG_WARN_MISSING_ASSERTIONS(true)
CATCH_CONFIG_SHOW_SUCCESS(true)
TEST_CASE_METHOD(UniqueTestsFixture, "M99", "[m_on]")
TEST_CASE_METHOD(UniqueTestsFixture, "M99", "[m_on][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(show);
@@ -69,7 +69,7 @@ namespace VisualStudioTests
getID();
}
TEST_CASE_METHOD(UniqueTestsFixture, "M12", "[m_off]")
TEST_CASE_METHOD(UniqueTestsFixture, "M12", "[m_off][vs]")
{
bool show = Catch::getCurrentContext().getConfig()->includeSuccessfulResults();
REQUIRE(!show);
@@ -95,16 +95,16 @@ namespace VisualStudioTests
REQUIRE(!show);
}
};
METHOD_AS_TEST_CASE(ConfigTest::run1,"M20", "[m_off]");
METHOD_AS_TEST_CASE(ConfigTest::run1,"M20", "[m_off][vs]");
CATCH_CONFIG_SHOW_SUCCESS(true)
METHOD_AS_TEST_CASE(ConfigTest::run2,"M21", "[m_on]");
METHOD_AS_TEST_CASE(ConfigTest::run2,"M21", "[m_on][vs]");
METHOD_AS_TEST_CASE(ConfigTest::run3,"M22", "[m_off]");
METHOD_AS_TEST_CASE(ConfigTest::run3,"M22", "[m_off][vs]");
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff, "[m_off]");
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff, "[m_off][vs]");
CATCH_CONFIG_SHOW_SUCCESS(true)
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOn, "[m_on]");
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff2, "[m_off]");
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOn, "[m_on][vs]");
CATCH_MAP_CATEGORY_TO_TAG(vstestsCheckOutputOff2, "[m_off][vs]");
}
#endif