UtestShell* TestRegistry::getTestWithNext(UtestShell* test)
{
    UtestShell* current = tests_;
    while (current && current->getNext() != test)
        current = current->getNext();
    return current;
}
void TestRegistry::listTestGroupAndCaseNames(TestResult& result)
{
    SimpleString groupAndNameList;

    for (UtestShell *test = tests_; test != NULL; test = test->getNext()) {
        if (testShouldRun(test, result)) {
            SimpleString groupAndName;
            groupAndName += "#";
            groupAndName += test->getGroup();
            groupAndName += ".";
            groupAndName += test->getName();
            groupAndName += "#";

            if (!groupAndNameList.contains(groupAndName)) {
                groupAndNameList += groupAndName;
                groupAndNameList += " ";
            }
        }
    }

    groupAndNameList.replace("#", "");

    if (groupAndNameList.endsWith(" "))
        groupAndNameList = groupAndNameList.subString(0, groupAndNameList.size() - 1);
    result.print(groupAndNameList.asCharString());
}
void TestRegistry::runAllTests(TestResult& result)
{
    bool groupStart = true;

    result.testsStarted();
    for (UtestShell *test = tests_; test != NULL; test = test->getNext()) {
        if (runInSeperateProcess_) test->setRunInSeperateProcess();
        if (runIgnored_) test->setRunIgnored();

        if (groupStart) {
            result.currentGroupStarted(test);
            groupStart = false;
        }

        result.countTest();
        if (testShouldRun(test, result)) {
            result.currentTestStarted(test);
            test->runOneTest(firstPlugin_, result);
            result.currentTestEnded(test);
        }

        if (endOfGroup(test)) {
            groupStart = true;
            result.currentGroupEnded(test);
        }
    }
    result.testsEnded();
    currentRepetition_++;
}
Exemple #4
0
void TestRegistry::shuffleRunOrder(rand_func_t rand_func)
{
    if (getFirstTest() == NULLPTR)
    {
        return;
    }
    const size_t numTests = getFirstTest()->countTests();
    typedef UtestShell* listElem;
    listElem* tests = new listElem[numTests];
    UtestShell *test = getFirstTest();
    for (size_t testsIdx = 0; testsIdx < numTests; ++testsIdx)
    {
        tests[testsIdx] = test;
        test = test->getNext();
    }
    shuffle_list(rand_func, numTests, reinterpret_cast<void**>(tests));

    // Store shuffled list back to linked list
    UtestShell *prev = NULLPTR;
    for (size_t i = 0; i < numTests; ++i)
    {
        prev = tests[numTests - 1 - i]->addTest(prev);
    }
    tests_ = prev;
    delete[] tests;
}
void MemoryReporterPlugin::postTestAction(UtestShell& test, TestResult& result)
{
	if (formatter_ == NULL) return;

	removeGlobalMemoryReportAllocators();
	formatter_->report_test_end(&result, test);

	if (test.getNext()->getGroup() != currentTestGroup_)
		formatter_->report_testgroup_end(&result, test);
}
UtestShell* TestRegistry::findTestWithGroup(const SimpleString& group)
{
    UtestShell* current = tests_;
    while (current) {
        if (current->getGroup() == group)
            return current;
        current = current->getNext();
    }
    return NULL;
}
UtestShell* TestRegistry::findTestWithName(const SimpleString& name)
{
    UtestShell* current = tests_;
    while (current) {
        if (current->getName() == name)
            return current;
        current = current->getNext();
    }
    return NULL;
}