Function runTest

Synopsis

#include <include/internal/catch_run_context.h>

Totals runTest(TestCase const &testCase)

Description

No description yet.

Source

Lines 131-170 in include/internal/catch_run_context.cpp. Line 47 in include/internal/catch_run_context.h.

Totals RunContext::runTest(TestCase const& testCase) {
    Totals prevTotals = m_totals;
    std::string redirectedCout;
    std::string redirectedCerr;
    auto const& testInfo = testCase.getTestCaseInfo();
    m_reporter->testCaseStarting(testInfo);
    m_activeTestCase = &testCase;
    ITracker& rootTracker = m_trackerContext.startRun();
    assert(rootTracker.isSectionTracker());
    static_cast<SectionTracker&>(rootTracker).addInitialFilters(m_config->getSectionsToRun());
    do {
        m_trackerContext.startCycle();
        m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo));
        runCurrentTest(redirectedCout, redirectedCerr);
    } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting());
    Totals deltaTotals = m_totals.delta(prevTotals);
    if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) {
        deltaTotals.assertions.failed++;
        deltaTotals.testCases.passed--;
        deltaTotals.testCases.failed++;
    }
    m_totals.testCases += deltaTotals.testCases;
    m_reporter->testCaseEnded(TestCaseStats(testInfo,
                              deltaTotals,
                              redirectedCout,
                              redirectedCerr,
                              aborting()));
    m_activeTestCase = nullptr;
    m_testCaseTracker = nullptr;
    return deltaTotals;
}





Add Discussion as Guest

Log in