int main(int argc, char** argv) { CppUnit::TestSuite suite; ExpTest expt("ExpTest"); ProgTest progt("ProgTest"); ProcTest proct("ProcTest"); RtlTest rtlt("RtlTest"); ParserTest parsert("ParserTest"); TypeTest typet("TypeTest"); expt.registerTests(&suite); progt.registerTests(&suite); proct.registerTests(&suite); rtlt.registerTests(&suite); parsert.registerTests(&suite); typet.registerTests(&suite); CppUnit::TextTestResult res; suite.run( &res ); std::cout << res << std::endl; return 0; }
int main() { // Using TestCase ComplexNumberTest cnt("Super test"); cnt.runTest(); // Using TestFixture CppUnit::TestCaller<ComplexNumberFixture> testForEquality("testEquality", &ComplexNumberFixture::testEquality); CppUnit::TestResult resultOfEquality; testForEquality.run(&resultOfEquality); CppUnit::TestCaller<ComplexNumberFixture> testForAddition("testAddition", &ComplexNumberFixture::testAddition); CppUnit::TestResult resultOfAddition; testForAddition.run(&resultOfAddition); // Using TestSuite /* // Math Suite CppUnit::TestSuite math_suite; math_suite.addTest(new CppUnit::TestCaller<ComplexNumberFixture> ("testAddition", &ComplexNumberFixture::testAddition)); */ CppUnit::TestSuite suite; CppUnit::TestResult suite_result; suite.addTest(new CppUnit::TestCaller<ComplexNumberFixture> ("testEquality", &ComplexNumberFixture::testEquality)); suite.addTest(new CppUnit::TestCaller<ComplexNumberFixture> ("testAddition", &ComplexNumberFixture::testAddition)); suite.addTest(ComplexNumberSuite::suite()); suite.run(&suite_result); // Using suite method CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); bool wasSuccessful = runner.run(); if (wasSuccessful) cout << "Was successful" << endl; else cout << "Was unsuccessful" << endl; Complex c(7); cout << c << endl; }
int main(int argc, char** argv) { CppUnit::TestSuite suite; LoaderTest lt("ExpTest"); lt.registerTests(&suite); CppUnit::TextTestResult res; suite.run( &res ); std::cout << res << std::endl; return 0; }
int main(int argc, char** argv) { CppUnit::TestSuite suite; // FrontSparcTest fst("FrontSparcTest"); // FrontendTest fet("FrontendTest"); // FrontPentTest fpt("FrontPentTest"); FrontPentTest fSt("FrontPentTest"); // fst.registerTests(&suite); // fpt.registerTests(&suite); fSt.registerTests(&suite); CppUnit::TextTestResult res; prog.readLibParams(); // Read library signatures (once!) suite.run( &res ); std::cout << res << std::endl; return 0; }
_EXPORT int BTestShell::Run(int argc, char *argv[]) { // Make note of which directory we started in UpdateTestDir(argv); // Parse the command line args if (!ProcessArguments(argc, argv)) return 0; // Load any dynamically loadable tests we can find LoadDynamicSuites(); // See if the user requested a list of tests. If so, // print and bail. if (fListTestsAndExit) { PrintInstalledTests(); return 0; } // Add the proper tests to our suite (or exit if there // are no tests installed). CppUnit::TestSuite suite; if (fTests.empty()) { // No installed tests whatsoever, so bail cout << "ERROR: No installed tests to run!" << endl; return 0; } else if (fSuitesToRun.empty() && fTestsToRun.empty()) { // None specified, so run them all TestMap::iterator i; for (i = fTests.begin(); i != fTests.end(); ++i) suite.addTest( i->second ); } else { set<string>::const_iterator i; set<string> suitesToRemove; // Add all the tests from any specified suites to the list of // tests to run (since we use a set, this eliminates the concern // of having duplicate entries). for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) { // See if it's a suite (since it may just be a single test) if (fSuites.find(*i) != fSuites.end()) { // Note the suite name for later removal unless the // name is also the name of an available individual test if (fTests.find(*i) == fTests.end()) { suitesToRemove.insert(*i); } const TestMap &tests = fSuites[*i]->getTests(); TestMap::const_iterator j; for (j = tests.begin(); j != tests.end(); j++) { fTestsToRun.insert( j->first ); } } } // Remove the names of all of the suites we discovered from the // list of tests to run (unless there's also an installed individual // test of the same name). for (i = suitesToRemove.begin(); i != suitesToRemove.end(); i++) { fTestsToRun.erase(*i); } // Everything still in fTestsToRun must then be an explicit test for (i = fTestsToRun.begin(); i != fTestsToRun.end(); ++i) { // Make sure it's a valid test if (fTests.find(*i) != fTests.end()) { suite.addTest( fTests[*i] ); } else { cout << endl << "ERROR: Invalid argument \"" << *i << "\"" << endl; PrintHelp(); return 0; } } } // Run all the tests InitOutput(); InstallPatches(); suite.run(&fTestResults); UninstallPatches(); PrintResults(); return 0; }