void TestRegistry::Finalize( int failureCount, int summaryCount) { std::string packet = ""; int numberOfTests = 0, numberOfSuccessfulTests = 0, numberOfUnsuccessfulTests = 0 ; for (ITest *test = tests_; test != 0; test = test->GetNext()) { numberOfTests++; if (test->Failed()) numberOfUnsuccessfulTests++; else numberOfSuccessfulTests++ ; } LPVOID tempPacket = TVTCreateXMLPacket4FinalizeSession( APPL_ID,failureCount,summaryCount, numberOfTests,numberOfSuccessfulTests,numberOfUnsuccessfulTests); bool result = TVTFinalize((const char*)tempPacket); TVTDeletePacket(tempPacket) ; }
int main() { ITest* pTest = ITest::createTest(); if(pTest->test()) std::cout<<"Test Passed"; else std::cout<<"Test Failed"; }
// main function int main (int argc, char **argv) { ITest * test = NULL; // create different test classes here test = new FallingForeverTest(); int ret = test->Run(argc, argv); delete test; return ret; }
void TestRegistry::Run (TestResult& result) { result.TestsStarted (); for (ITest *test = tests_; test != 0; test = test->GetNext()) { test->Run(result); test->Analysis(result.Statistics(),result.Trace()); } Finalize(result.Failures(),result.Summary()); result.TestsEnded(testsNumber_); }
/** * Run the next text from the array. */ void ApplicationController::runNextTest() { if (mTests.size() == 0) { this->finishTesting(); return; } this->log("================================"); ITest* test = mTests[0]; char buffer[BUF_MAX]; sprintf(buffer, "Started %s", test->getTestName().c_str()); this->log(buffer); test->startTest(); }
/** * Notify controller that a test has failed. * @param test Test that failed. */ void ApplicationController::testFailed(ITest& test) { this->log(test.getReason()); this->log("Test failed!"); this->log("================================"); MAUtil::String* testName = new MAUtil::String(test.getTestName()); mFailedTests.add(testName); ITest* testAux = mTests[0]; mTests.remove(0); delete testAux; this->runNextTest(); }
void RunAllTests() { #ifdef DEBUG_UNITTEST std::cout << "Running tests\n"; #endif for( auto factoryFunction : TestFactories() ) { ITest* test = static_cast<ITest*>( factoryFunction.second() ); try { std::cout << "Running test \"" << test->GetTestName() << "\"\n"; test->Run(); std::cout << "... Test \"" << test->GetTestName() << "\" successful\n"; } catch( Assertions::NotEqualException& ex ) { std::cout << "... Test \"" << test->GetTestName() << "\" failed:\n" << ex.what() << "\n"; } catch( Assertions::EqualException& ex ) { std::cout << "... Test \"" << test->GetTestName() << "\" failed:\n" << ex.what() << "\n"; } catch( Assertions::ExceptionNotThrownException& ex ) { std::cout << "... Test \"" << test->GetTestName() << "\" failed:\n" << ex.what() << "\n"; } catch( Assertions::WrongExceptionCaughtException& ex ) { std::cout << "... Test \"" << test->GetTestName() << "\" failed:\n" << ex.what() << "\n"; } catch( Assertions::ReportCoreFailureException& ex ) { /// @todo Better way to report un-recoverable failure, like this one, when You can't /// continue with testing std::cout << "Received Core Failure exception. This means we cannot continue " << "testing because we cannot ensure test results will be correct.\n" << "The message of Core Failure exception:\n" << ex.what() << '\n'; delete test; return; } catch(...) { std::cout << "... Test \"" << test->GetTestName() << "\" failed:\n{unknown}\n"; throw; } delete test; } }
unsigned long search(TSearchInfo pSearchInfo, unsigned long pExpResults, unsigned int *pFlags = NULL) { unsigned int lFlags = 0; TV_R(!pSearchInfo.empty(), mTest); uint64_t cntResults = 0 ; CmvautoPtr<IStmt> ftQ(mSession->createStmt()) ; unsigned char lVar = ftQ->addVariable() ; TSearchInfo::const_iterator lIter = pSearchInfo.begin(); int i = 0; for(; lIter != pSearchInfo.end(); lIter++, i++) { //string strFlags; //if ( pFlags[i] & QFT_FILTER_SW ) strFlags.append( "QFT_FILTER_SW "); //if ( pFlags[i] & MODE_ALL_WORDS ) strFlags.append( "MODE_ALL_WORDS "); PropertyID lPropID = lIter->first; Tstring lSearchKey = lIter->second; unsigned int flagsToAddConditionFT = 0; if (pFlags && pFlags[i]) { lFlags |= pFlags[i]; if (pFlags[i] & QFT_FILTER_SW) { flagsToAddConditionFT |= QFT_FILTER_SW; lFlags &= ~QFT_FILTER_SW ; } } TVRC_R( ftQ->addConditionFT( lVar, lSearchKey.c_str(), flagsToAddConditionFT, &lPropID, 1), mTest); } TVRC_R( ftQ->count( cntResults, NULL, 0, ~0, lFlags ), mTest ); ICursor* lC = NULL; ftQ->execute(&lC, NULL, 0, ~0, 0, lFlags); CmvautoPtr<ICursor> res(lC); PID lPID ; unsigned long cntCheck = 0 ; while( RC_OK == res->next(lPID) ) { if (mTest->isVerbose()) MVTApp::output(lPID, std::cout, mSession); cntCheck++ ; } TV_R(cntCheck == pExpResults, mTest) ; TV_R(cntCheck == cntResults, mTest) ; return (unsigned long)cntResults ; }