6

So I'm attempting to run an XCode UI Test on my React Native project. My goal is to use fastlane/snapshot to grab screenshots of my app.

I finally figured out how to script my app to do what I want. Unfortunately, the app gets stuck with an App failed to quiesce within 60s message after calling app.otherElements["mainButton"].tap().

As far as I can tell as a human, my app appears to be static and not updating or animating anything. But I'm not clear what the UI Test is using for its detection heuristic, so it might be using some internal state or checking threads.

I suspect there's some React Native behavior that's keeping the UI Test from seeing things as finished. Unfortunately, without any real ability to see what UI Tests are doing, I'm not even sure where I need to dig into React Native to fix it. :(

Any help would be appreciated!

4

1 回答 1

1

上面链接中的解决方法对于有问题的视图和禁用动画的行

viewWillAppear:
- (void) viewWillAppear: (BOOL)animated {  
    if ([[[NSProcessInfo processInfo] environment][@"UITEST_DISABLE_ANIMATIONS"] isEqualToString:@"YES"]) {  
        [UIView setAnimationsEnabled:NO];  
    }  
}  

并在 viewWillDisappear 中重新打开动画:

- (void) viewWillDisappear:(BOOL)animated {  
    if ([[[NSProcessInfo processInfo] environment][@"UITEST_DISABLE_ANIMATIONS"] isEqualToString:@"YES"]) {  
        [UIView setAnimationsEnabled:YES];  
    }  
}  

在您的测试中扩展 XCUIApplication 并设置变量。然后在您的 setup 方法中调用该 launchvariables 函数

extension XCUIApplication {  
    func launchTestsWithEnvironmentVariables() {  
             launchEnvironment = [  
                 "UITEST_DISABLE_ANIMATIONS" : "YES"  
             ]  
     self.launch()  
    }  
}  




 override func setUp() {  
        super.setUp()  
        continueAfterFailure = false  
        XCUIApplication().launchTestsWithEnvironmentVariables()  
    }  




func testblahblah {  

这将设置一个环境变量,该变量将禁用该特定视图的动画。唯一的缺点是,如果您喜欢的话,您将不会测试该视图的动画。哈克的解决方法,但它现在有效。

PS它真的对我有帮助

于 2016-09-04T14:22:22.293 回答