Unverified Commit 111a7d01 authored by hellohuanlin's avatar hellohuanlin Committed by GitHub

[platform_view]retry launch if it fails to launch for xcuitest (#110030)

parent 129fa769
......@@ -26,16 +26,32 @@ static const CGFloat kStandardTimeOut = 60.0;
[super setUp];
self.continueAfterFailure = NO;
// Retry launching the app if it fails to launch.
// This is trying to fix a "failed to terminate" failure, which is likely a bug in Xcode.
// The solution is based on https://stackoverflow.com/questions/41872848/xctests-failing-to-launch-app-in-simulator-intermittently
int remainingLaunchCount = 10;
while (true) {
self.app = [[XCUIApplication alloc] init];
[self.app launch];
remainingLaunchCount -= 1;
[NSThread sleepForTimeInterval:3];
if (self.app.exists) {
// success launch
break;
}
if (remainingLaunchCount > 0) {
NSLog(@"Retry launch with remaining launch count %d", remainingLaunchCount);
[self.app terminate];
[NSThread sleepForTimeInterval:3];
continue;
}
NSLog(@"Failed to launch");
}
}
- (void)tearDown {
// This is trying to fix a "failed to terminate" failure, which is likely a bug in Xcode.
// In theory the terminate call is not necessary, but many has encountered this similar
// issue, and fixed it by terminating the app and relaunching it if needed for each test.
// Here we simply try terminating the app in tearDown, but if it does not work,
// then alternative solution is to terminate and relaunch the app.
[self.app terminate];
[super tearDown];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment