28 #ifndef PT_UNIT_TESTMAIN_H
29 #define PT_UNIT_TESTMAIN_H
33 #include <Pt/Unit/Api.h>
34 #include <Pt/Unit/Reporter.h>
35 #include <Pt/Unit/Application.h>
46 int main(
int argc,
char** argv)
55 std::cerr <<
"Usage: " << argv[0] <<
" [-t <testname>] [-f <logfile>]\n";
56 std::cerr <<
"Available Tests:\n";
57 std::list<Pt::Unit::Test*>::const_iterator it;
58 for( it = app.
tests().begin(); it != app.
tests().end(); ++it)
60 std::cerr <<
" - "<< (*it)->name() << std::endl;
65 Pt::Unit::BriefReporter consoleReporter;
69 std::ofstream logFile;
70 Pt::Unit::BriefReporter fileReporter;
71 std::string fileName = file.get();
73 if( ! fileName.empty() )
75 logFile.open( fileName.c_str() );
76 fileReporter.setOutput(logFile);
82 std::string testName = test.get();
83 if( testName.empty() )
96 catch(
const std::exception& ex)
98 std::cerr << ex.what() << std::endl;
104 #endif// PT_UNIT_TESTMAIN_H
void run(const std::string &testName)
Run test by name.
Read and extract command-line options.
Definition: Arg.h:199
Run registered tests.
Definition: Application.h:64
static std::list< Test * > & tests()
Returns a list of all registered test TODO: find another way to query available tests.
unsigned errors() const
Returns the number of errors which occured during a run.
Definition: Application.h:116
void attachReporter(Reporter &r)
Add reporter for test events.