Result * Suite::run(){ setupTests(); Result * r = new Result( _name ); Result::cur = r; for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ){ TestCase * tc = *i; r->_tests++; bool passes = false; log(1) << "\t" << tc->getName() << endl; try { tc->run(); passes = true; } catch ( ... ){ log() << "unknown exception in test: " << tc->getName() << endl; } if ( ! passes ) r->_fails++; } return r; }
Result * Suite::run( const std::string& filter, int runsPerTest ) { log(1) << "\t about to setupTests" << std::endl; setupTests(); log(1) << "\t done setupTests" << std::endl; Result * r = new Result( _name ); Result::cur = r; for ( std::vector<TestHolder*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ) { TestHolder* tc = *i; if ( filter.size() && tc->getName().find( filter ) == std::string::npos ) { log(1) << "\t skipping test: " << tc->getName() << " because doesn't match filter" << std::endl; continue; } r->_tests++; bool passes = false; onCurrentTestNameChange( tc->getName() ); log() << "\t going to run test: " << tc->getName() << std::endl; std::stringstream err; err << tc->getName() << "\t"; try { for ( int x=0; x<runsPerTest; x++ ) tc->run(); passes = true; } catch ( const TestAssertionFailureException& ae ) { err << ae.toString(); } catch ( const std::exception& e ) { err << " std::exception: " << e.what() << " in test " << tc->getName(); } catch ( int x ) { err << " caught int " << x << " in test " << tc->getName(); } if ( ! passes ) { std::string s = err.str(); log() << "FAIL: " << s << std::endl; r->_fails++; r->_messages.push_back( s ); } } if ( r->_fails ) r->_rc = 17; onCurrentTestNameChange( "" ); log() << "\t DONE running tests" << std::endl; return r; }
Result * Suite::run(){ tlogLevel = -1; log(1) << "\t about to setupTests" << endl; setupTests(); log(1) << "\t done setupTests" << endl; Result * r = new Result( _name ); Result::cur = r; /* see note in SavedContext */ //writelock lk(""); for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ){ TestCase * tc = *i; r->_tests++; bool passes = false; log(1) << "\t going to run test: " << tc->getName() << endl; stringstream err; err << tc->getName() << "\t"; try { tc->run(); passes = true; } catch ( MyAssertionException * ae ){ err << ae->ss.str(); delete( ae ); } catch ( std::exception& e ){ err << " exception: " << e.what(); } catch ( int x ){ err << " caught int : " << x << endl; } catch ( ... ){ cerr << "unknown exception in test: " << tc->getName() << endl; } if ( ! passes ){ string s = err.str(); log() << "FAIL: " << s << endl; r->_fails++; r->_messages.push_back( s ); } } if ( r->_fails ) r->_rc = 17; log(1) << "\t DONE running tests" << endl; return r; }
Result * Suite::run( const std::string& filter, int runsPerTest ) { setupTests(); Result * r = new Result( _name ); Result::cur = r; for ( std::vector<TestHolder*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ) { TestHolder* tc = *i; r->_tests++; bool passes = false; std::cerr << "\t going to run test: " << tc->getName() << std::endl; std::stringstream err; err << tc->getName() << "\t"; try { for ( int x=0; x<runsPerTest; x++ ) tc->run(); passes = true; } catch ( const TestAssertionFailureException& ae ) { err << ae.toString(); } catch ( const std::exception& e ) { err << " std::exception: " << e.what() << " in test " << tc->getName(); } catch ( int x ) { err << " caught int " << x << " in test " << tc->getName(); } if ( ! passes ) { std::string s = err.str(); std::cerr << "FAIL: " << s << std::endl; r->_fails.push_back(tc->getName()); r->_messages.push_back( s ); } } if ( !r->_fails.empty() ) r->_rc = 17; std::cerr << "\t DONE running tests" << std::endl; return r; }
Result * Suite::run(){ setupTests(); Result * r = new Result( _name ); Result::cur = r; for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ){ TestCase * tc = *i; r->_tests++; bool passes = false; log(1) << "\t" << tc->getName() << endl; stringstream err; err << tc->getName() << "\t"; try { tc->run(); passes = true; } catch ( MyAssertionException * ae ){ err << ae->ss.str(); delete( ae ); } catch ( std::exception& e ){ err << " exception " << " : " << e.what(); } catch ( int x ){ err << " caught int : " << x << endl; } catch ( ... ){ cerr << "unknown exception in test: " << tc->getName() << endl; } if ( ! passes ){ r->_fails++; r->_messages.push_back( err.str() ); } } return r; }
Result * Suite::run( const string& filter ) { // set tlogLevel to -1 to suppress tlog() output in a test program tlogLevel = -1; log(1) << "\t about to setupTests" << endl; setupTests(); log(1) << "\t done setupTests" << endl; Result * r = new Result( _name ); Result::cur = r; /* see note in SavedContext */ //writelock lk(""); for ( list<TestCase*>::iterator i=_tests.begin(); i!=_tests.end(); i++ ) { TestCase * tc = *i; if ( filter.size() && tc->getName().find( filter ) == string::npos ) { log(1) << "\t skipping test: " << tc->getName() << " because doesn't match filter" << endl; continue; } r->_tests++; bool passes = false; log(1) << "\t going to run test: " << tc->getName() << endl; stringstream err; err << tc->getName() << "\t"; { scoped_lock lk(minutesRunningMutex); minutesRunning = 0; currentTestName = tc->getName(); } try { tc->run(); passes = true; } catch ( MyAssertionException * ae ) { err << ae->ss.str(); delete( ae ); } catch ( std::exception& e ) { err << " exception: " << e.what(); } catch ( int x ) { err << " caught int : " << x << endl; } catch ( ... ) { cerr << "unknown exception in test: " << tc->getName() << endl; } if ( ! passes ) { string s = err.str(); log() << "FAIL: " << s << endl; r->_fails++; r->_messages.push_back( s ); } } if ( r->_fails ) r->_rc = 17; log(1) << "\t DONE running tests" << endl; return r; }