Beispiel #1
0
	Result runTestCase (const TestCase& testCase)
	{
		Result result;
		printf ("%s\n", testCase.getName ().c_str());
		intend++;
		for (auto& it : testCase)
		{
			try {
				if (testCase.setup ())
				{
					testCase.setup () (this);
				}
				if (runTest (it.first, it.second))
				{
					result.succeded++;
				}
				else
				{
					result.failed++;
				}
				if (testCase.teardown ())
				{
					testCase.teardown () (this);
				}
			} catch (const std::exception& exc)
			{
				result.failed++;
			}
		}
		intend--;
		return result;
	}
Beispiel #2
0
void
TestSuite::run(TestResult *result, TestOption *opt)
{
  list<TestCase *>::iterator iter;
  
  iter = this->tests.begin();
  while (iter != this->tests.end()) {
    TestCase *tc = *iter;

    if (opt->verbose)
      cout << "Starting test " << tc->name << "\n";

    tc->result = result;
    try {
      tc->setup();

      result->n_run++;
      tc->statusSet = false;
      tc->run();

      if (tc->statusSet == false) {
	result->n_fail++;
	result->tests_f.push_back( tc->name );
      }

    }
    catch (TestFailure e) {
      TestFailure::setUnwindDone();
      if (opt->verbose)
	cout << "    caught test fail exception\n";
      result->tests_e.push_back( tc->name + e.what() );
      result->n_exceptions++;
    }
    if (opt->verbose)
      cout << "    done\n";

    iter++;
  }

  return;
}