private:
void List(Test *test, const string& parent = "") const;
+ // call List() if m_list or runner.addTest() otherwise
+ void AddTest(CppUnit::TestRunner& runner, Test *test)
+ {
+ if (m_list)
+ List(test);
+ else
+ runner.addTest(test);
+ }
+
// command lines options/parameters
bool m_list;
bool m_longlist;
for (size_t i = 0; i < parser.GetParamCount(); i++)
m_registries.push_back(parser.GetParam(i));
}
- else
- {
- // FIXME: this is an ugly and unnecessary hack
- m_registries.push_back("");
- }
m_longlist = parser.Found("longlist");
m_list = m_longlist || parser.Found("list");
CppUnit::TextTestRunner runner;
- for (size_t i = 0; i < m_registries.size(); i++)
+ if ( m_registries.empty() )
{
- Test *test;
-
- wxString reg = m_registries[i];
- if ( reg.empty() )
- {
- // no test name, run all the tests
- test = TestFactoryRegistry::getRegistry().makeTest();
- }
- else // test name specified, run just this test
+ // run or list all tests
+ AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());
+ }
+ else // run only the selected tests
+ {
+ for (size_t i = 0; i < m_registries.size(); i++)
{
- test = GetTestByName(reg);
+ const wxString reg = m_registries[i];
+ Test *test = GetTestByName(reg);
if ( !test && !reg.EndsWith("TestCase") )
{
cerr << "No such test suite: " << string(reg.mb_str()) << endl;
return 2;
}
- }
- if (m_list)
- List(test);
- else
- runner.addTest(test);
+ AddTest(runner, test);
+ }
}
if ( m_list )