Пример #1
0
USING_NAMESPACE_CPPUNIT

void TestCallerTest::runTest()
{
#ifdef cu_NO_TEMPLATES
	typedef TestCaller(TestCallerTestCase) Caller;
#else
	typedef TestCaller<TestCallerTestCase> Caller;
#endif
	cu_AUTO_PTR(Caller) test(new TEST_CALLER(TestCallerTestCase, testRun));
	const char* testName = "TestCallerTestCase::testRun";
	TEST_ASSERT_EQUALS(1, test->countTestCases());
	TEST_ASSERT_EQUALS(testName, test->getName());
	TEST_ASSERT_EQUALS(testName, test->toString());

	TestResult result;
	test->run(&result);
	TEST_ASSERT(test->fixture()->wasSetUp);
	TEST_ASSERT(test->fixture()->wasRun);
	TEST_ASSERT(test->fixture()->wasTornDown);
	TEST_ASSERT_EQUALS(1, result.runCount());
	TEST_ASSERT_EQUALS(1, result.failureCount());
	TEST_ASSERT_EQUALS(1, result.errorCount());
	TEST_ASSERT(!result.wasSuccessful());
}
Пример #2
0
void TestSetupTest::testTearDownError()
{
	TearDownErrorTestSetup
	test(new TestCaseTest::FailureTestCase("FailureTestCase"));
	TEST_ASSERT_EQUALS(1, test.countTestCases());
	TEST_ASSERT_EQUALS("FailureTestCase", test.getName());
	TEST_ASSERT_EQUALS("FailureTestCase", test.toString());

	TestResult result;
	test.run(&result);
	TEST_ASSERT(test.wasSetUp);
	TEST_ASSERT(!test.wasTornDown);
	TEST_ASSERT_EQUALS(1, result.runCount());
	TEST_ASSERT_EQUALS(1, result.failureCount());
	TEST_ASSERT_EQUALS(1, result.errorCount());
	TEST_ASSERT(!result.wasSuccessful());
}
Пример #3
0
USING_NAMESPACE_CPPUNIT

void TestSetupTest::testTestSetup()
{
	TestSuite* suite = new TestSuite("2Tests");
	suite->addTest(new TestCaseTest::SuccessTestCase("SuccessTestCase"));
	suite->addTest(new TestCaseTest::FailureTestCase("FailureTestCase"));
	TestTestSetup test(suite);
	TEST_ASSERT_EQUALS(2, test.countTestCases());
	TEST_ASSERT_EQUALS("2Tests", test.getName());
	TEST_ASSERT_EQUALS("suite 2Tests", test.toString());

	TestResult result;
	test.run(&result);
	TEST_ASSERT(test.wasSetUp);
	TEST_ASSERT(test.wasTornDown);
	TEST_ASSERT_EQUALS(2, result.runCount());
	TEST_ASSERT_EQUALS(1, result.failureCount());
	TEST_ASSERT_EQUALS(0, result.errorCount());
	TEST_ASSERT(!result.wasSuccessful());
}