void SDKUnitTestListener::OnTestCaseEnd(const TestCase& test_case) {
	if (!GTEST_FLAG(print_time)) return;

	const std::string counts = FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
	PushResult( "[----------] " );
	PushResult( UTIL_VarArgs("%s from %s (%s ms total)\n\n",
		counts.c_str(), test_case.name(),
		internal::StreamableToString(test_case.elapsed_time()).c_str() ) );
}
Beispiel #2
0
// Called before the test case starts.
void TersePrinter::OnTestCaseStart(const TestCase& test_case)
{
	if (useTerseOutput) return;

	ColoredPrintf(COLOR_GREEN, "[----------] ");
	printf("%s from %s\n",
	       FormatTestCount(test_case.test_to_run_count()).c_str(),
	       test_case.name());
	fflush(stdout);
}
Beispiel #3
0
void TestListView::onListTestsFinished(void) {

    // sanity check
    Q_ASSERT_X(m_runner, Q_FUNC_INFO, "null test runner");
    if ( m_runner == 0 )
        return;

    // clear any previous data (necessary here?)
    clear();

    // foreach program
    const int numPrograms = m_runner->programCount();
    for ( int i = 0; i < numPrograms; ++i ) {
        TestProgram* program = m_runner->programAt(i);
        Q_ASSERT_X(program, Q_FUNC_INFO, "null test program");

        // create top-level item for program
        QTreeWidgetItem* programItem = new QTreeWidgetItem;
        programItem->setData(0, Qt::DisplayRole, program->programName());
        programItem->setData(0, Qt::UserRole, QVariant::fromValue(program));
//        programItem->setCheckState(0, Qt::Checked);

        // foreach test suite
        const int numSuites = program->suiteCount();
        for ( int j = 0; j < numSuites; ++j ) {
            TestSuite* suite = program->suiteAt(j);
            Q_ASSERT_X(suite, Q_FUNC_INFO, "null test suite");

            // create item for suite
            QTreeWidgetItem* suiteItem = new QTreeWidgetItem(programItem);
            suiteItem->setData(0, Qt::DisplayRole, suite->name());
            suiteItem->setData(0, Qt::UserRole, QVariant::fromValue(suite));
//            suiteItem->setCheckState(0, Qt::Checked);

            // foreach test case
            const int numTests = suite->testCount();
            for ( int k = 0; k < numTests; ++k ) {
                TestCase* test = suite->testAt(k);
                Q_ASSERT_X(test, Q_FUNC_INFO, "null test case");

                // create item for test
                QTreeWidgetItem* testItem = new QTreeWidgetItem(suiteItem);
                testItem->setData(0, Qt::DisplayRole, test->name());
                testItem->setData(0, Qt::UserRole, QVariant::fromValue(test));
//                testItem->setCheckState(0, Qt::Checked);
            }
        }

        // add program item to table
        addTopLevelItem(programItem);
    }

    // start with all items collapsed
    collapseAll();
}
void SDKUnitTestListener::OnTestCaseStart(const TestCase& test_case) {
	const std::string counts =
		FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
	PushResult( "[----------] " );
	PushResult( UTIL_VarArgs("%s from %s", counts.c_str(), test_case.name()) );
	if (test_case.type_param() == NULL) {
		PushResult( "\n" );
	} else {
		PushResult( UTIL_VarArgs(", where %s = %s\n", kTypeParamLabel, test_case.type_param()) );
	}
}
Beispiel #5
0
// Called after the test case ends.
void TersePrinter::OnTestCaseEnd(const TestCase& test_case)
{
	// a test case end is not printed for the following
	if (useTerseOutput || !GTEST_FLAG(print_time))
		return;

	ColoredPrintf(COLOR_GREEN, "[----------] ");
	printf("%s from %s (%s ms total)\n\n",
	       FormatTestCount(test_case.test_to_run_count()).c_str(),
	       test_case.name(),
	       internal::StreamableToString(test_case.elapsed_time()).c_str());
	fflush(stdout);
}
Beispiel #6
0
  bool TestRunner::visit(TestCase& test)
  {
    if (m_context->shouldStop())
      return false;
    if (!shouldVisit(currentPath() + test.name()))
      return false;

    int rst = runTestCase(test, *m_context, logS());
    if( 0 != rst )
        m_failures++;
    
    m_tests++;
    // Always continue, regardless of test result, unless the context
    // object says otherwise.
    return !m_context->shouldStop();
  }
Beispiel #7
0
int main()
{
    std::sort(TestCase::allTests().begin(), TestCase::allTests().end(), TestComparator());

    DebuggingTestImpl::get()->printf("Starting tests\n");

    bool anyFailed = false;

    for(int i = 0; i < (int)TestCase::allTests().size(); ++i)
    {
        if(i > 0)
            DebuggingTestImpl::get()->printf("");

        TestCase *test = TestCase::allTests()[i];
        string name = test->name();
        DebuggingTestImpl::get()->printf("running %s", name.c_str());
        bool failed = true;
        try
        {
            DebuggingTestImpl::get()->startTiming(name);
            DebuggingTestImpl::get()->indent();
            test->run();
            failed = false;
            DebuggingTestImpl::get()->unindent();
        }
        catch(Assertion)
        {
            DebuggingTestImpl::get()->unindent();
        }
        catch(...)
        {
            DebuggingTestImpl::get()->unindent();
            DebuggingTestImpl::get()->printf("Exception thrown");
        }
        DebuggingTestImpl::get()->elapsedTime(name);
        if(failed)
            DebuggingTestImpl::get()->printf("FAILED! %s", name.c_str());
        else
            DebuggingTestImpl::get()->printf("passed  %s", name.c_str());
        anyFailed = anyFailed || failed;
    }

    return anyFailed ? 1 : 0;
}
Beispiel #8
0
 /*
  * run the test case
  * return 0 for pass. -1 for fail.
  */
 inline int runTestCase( TestCase & test, TestContext & context, std::ostream & log)
 {
   int rst = 0;
   try {
     test.run(context);
     log << test.name() << " Passed " << std::endl;
     rst = 0;
   }
   catch (XTestFailure& e) {
     log << outputLine(e.m_file, e.m_line) << e.what() << '\n' << "FAILED: ";
     rst = -1;
   }
   catch (std::exception& e) {
     log << outputLine(__FILE__, __LINE__)
         << "caught standard exception - " << e.what() << '\n'
         << "FAILED: ";
     rst = -1;
   }
   return rst;
 }