简体   繁体   中英

How to re-initialize the Google Test Framework

Continueing from the previous question .

The requirment is for Google Test. Once I google test tracks Teast case "Rasmi" . It should re-run Hi then it will run Rasmi . Making things clear:-

vect.push_back("Hello"); 
vect.push_back("Hi"); 
vect.push_back("Rasmi"); 
for(vect<string>::iterator it = vect.begin(); it != vect.end(); ++it) 
{  
if(*it == "Rasmi") // If it encounters "Rasmi"     
{ 
//it--;    
int index = it - vect.begin ();       
vect.insert(vect.begin()+2, "Hi");  
it = vect.begin () + index;    
}    
cout << *it; 
} 

In this case when it reruns testcase Hi it just copies and pasted the previous executed test case. That is why test case Rasmi fails. But if all runs with out any conditions like

Hello->Hi->Rasmi... The execution becomes successful.

Please help me how to reinitialize GoogleTest.

If you are using singletons, then there could be something left over from the previous test (we have this problem where I currently work).

How about each test cleans up any changes it made to global objects before exiting?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM