22 #include <cppunit/Test.h>
23 #include <cppunit/TestSuite.h>
24 #include <cppunit/extensions/TestFactoryRegistry.h>
25 #include <cppunit/extensions/RepeatedTest.h>
26 #include <cppunit/ui/text/TestRunner.h>
28 #if defined(ONLY_HEADLESS_TESTS)
29 #include <QCoreApplication>
31 #include <QApplication>
44 CppUnit::TestSuite* testSuite =
dynamic_cast<CppUnit::TestSuite *
>(tests);
45 CppUnit::Test* testFound = NULL;
48 if (testSuite != NULL) {
49 if (testSuite->getName() == name) {
52 std::vector<CppUnit::Test*> allTestsVector = testSuite->getTests();
53 std::vector<CppUnit::Test*>::iterator testIterator;
54 for (testIterator = allTestsVector.begin();
55 testIterator != allTestsVector.end();
66 if (tests->getName() == name) {
76 CppUnit::Test * wholeRegistry = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
77 if (testNames.empty())
80 CppUnit::TestSuite * testSuite =
new CppUnit::TestSuite(
"");
81 cisstTestParameters::TestNameContainerType::const_iterator nameIterator
83 while (nameIterator != testNames.end()) {
86 testSuite->addTest(test);
88 std::cerr <<
"Failed to instantiate " << (*nameIterator) << std::endl;
101 CppUnit::TestSuite* testSuite =
dynamic_cast<CppUnit::TestSuite *
>(tests);
103 if (testSuite != NULL) {
104 std::vector<CppUnit::Test*> allTestsVector = testSuite->getTests();
105 std::vector<CppUnit::Test*>::iterator testIterator;
106 for (testIterator = allTestsVector.begin();
107 testIterator != allTestsVector.end();
114 std::cout << tests->getName() << std::endl;
124 CppUnit::TestSuite* testSuite =
dynamic_cast<CppUnit::TestSuite *
>(tests);
126 if (testSuite != NULL) {
127 std::vector<CppUnit::Test*> allTestsVector = testSuite->getTests();
128 std::vector<CppUnit::Test*>::iterator testIterator;
129 for (testIterator = allTestsVector.begin();
130 testIterator != allTestsVector.end();
137 std::cout <<
"ADD_TEST(\""
139 <<
"\" " << programName
155 int main(
int argc,
char *argv[])
164 CppUnit::TestSuite * allTests =
new CppUnit::TestSuite(
"All Tests");
166 for (instanceCounter = 0; instanceCounter < testParameters.
GetNumInstances(); ++instanceCounter) {
177 std::cout <<
"#generating done!" << std::endl;
183 #if defined(ONLY_HEADLESS_TESTS)
184 QCoreApplication app(argc, argv);
190 CppUnit::RepeatedTest * repeatedTest =
192 CppUnit::TextUi::TestRunner runner;
193 runner.addTest(repeatedTest);
194 bool wasSuccessful = runner.run();
int GetNumIterations() const
TestRunModeType GetTestRunMode() const
int main(int argc, char *argv[])
const TestNameContainerType & GetTestNames() const
CppUnit::Test * FindTestInTestSuite(CppUnit::Test *tests, const std::string &name)
int GetNumInstances() const
std::string GetProgramName(void) const
int ListAllTestsInTestSuite(CppUnit::Test *tests)
int GenerateCTestFile(CppUnit::Test *tests, const std::string &programName)
std::list< std::string > TestNameContainerType
static int PrintHelp(const char *programName)
CppUnit::Test * InstantiateTests(const cisstTestParameters::TestNameContainerType &testNames)
void ParseCmdLine(int argc, char *argv[])