本文整理汇总了C++中TestCase::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ TestCase::getName方法的具体用法?C++ TestCase::getName怎么用?C++ TestCase::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestCase
的用法示例。
在下文中一共展示了TestCase::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupTests
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;
}
示例2: log
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;
}
示例3: runTestCase
Result runTestCase (const TestCase& testCase)
{
Result result;
printf ("%s\n", testCase.getName ().c_str());
intend++;
for (auto& it : testCase)
{
try {
if (testCase.setup ())
{
testCase.setup () (this);
}
if (runTest (it.first, it.second))
{
result.succeded++;
}
else
{
result.failed++;
}
if (testCase.teardown ())
{
testCase.teardown () (this);
}
} catch (const std::exception& exc)
{
result.failed++;
}
}
intend--;
return result;
}
示例4: setupTests
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;
}
示例5: runNextCaseHelper
void TestSuite::runNextCaseHelper()
{
TestCase* testCase;
// There must be test cases to run.
if (mTestCases.size() > 0)
{
// Increment test case index.
mCurrentTestCase ++;
// Is this the first test case?
if (0 == mCurrentTestCase)
{
// Signal beginning of the test suite.
fireBeginTestSuite(mName);
}
// If this is not the first test case then
// signal the end of the previous test case.
else
{
// Close/clear the previous test case.
testCase = mTestCases[mCurrentTestCase - 1];
testCase->clearTimeOut();
testCase->close();
fireEndTestCase();
}
// If last test case has been run, reset the
// test case index and end the suite.
if (mCurrentTestCase >= mTestCases.size())
{
mCurrentTestCase = -1;
fireEndTestSuite();
return;
}
// Get the current test case.
testCase = mTestCases[mCurrentTestCase];
// Open the current test case.
fireBeginTestCase(testCase->getName());
testCase->open();
// Run current test case.
testCase->start();
// Note: We do not call fireEndTestCase() here,
// because it should not be called until the
// current test case has called runNextTestCase().
}
}
示例6: print
void DefaultTestPrinter::print( const TestResult *testResult )
{
int failures;
int successes;
int errors;
std::string state;
std::string name;
TestCase *testCase = testResult->getTestCases();
int size = testResult->getTestCaseCount();
printHeader( testResult );
if ( testResult->getTestCaseRanCount() == 0 )
{
fprintf( output_, "No test ran\n" );
}
for ( int i = 0;i < size;i++ )
{
if ( testCase->ran() )
{
name = testCase->getName();
failures = testCase->getFailuresCount();
successes = testCase->getSuccessesCount();
errors = testCase->getErrorsCount();
if ( failures > 0 || errors > 0 )
{
state = "FAILED";
}
else
{
state = "PASSED";
}
fprintf( output_, "Test case \"%s\" %s with %d error(s), %d failure(s) and %d success(es):\n", name.c_str(), state.c_str(), errors, failures, successes );
printTests( testCase );
fprintf( output_, "\n" );
}
testCase = testCase->getNext();
}
}
示例7: lk
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;
}