XCUITest

Has anyone had any luck using the new UI testing yet? I would love to port all of the asynchronous javascript automation testing since in theory this will work better, but I haven't been able to get very far before tests fail with

t = 8.50s Wait for app to idle

t = 38.52s Assertion Failure: UI Testing Failure - App failed to quiesce within 30.0s

/Users/jos/GIT/xxx/xxx/xxx/xxx/xxxUITests.swift:41: error: -[xxxUITests.xxxUITests testDropbox] : UI Testing Failure - App failed to quiesce within 30.0s


Has ANYONE had any luck using this? This is even more frustrating than automating with javascript!


jos

A repeat would seem to an anti-pause, no?

I have this exact same issue, where I have some animations that run on repeat. If I dont run them, the tests work, if I run them once the tests work.


[UIView animateWithDuration:7.0 delay:0 options:UIViewAnimationOptionRepeat animations:^{

cloudleft.center = CGPointMake(cloudleft.center.x + self.view.frame.size.width + 100, cloudleft.center.y);

} completion:^(BOOL finished) {

}];


Is there a way to get round this as its blocking using what really is useful addition to XCode 7 for me.


Is there a way to tell the tests that im idle and it can continue ?

I am facing the similar problem and looking for a way to make it work.

I'm not aware of seeing this issue outlined in bug reports. Please amke sure that each one of you file a bug report describing your use case (repeating animations), and that they're blocking your ability to use UI testing.


For now perhaps you can make these animations block after one iteration, to allow you to still use UI testing?

THIS! This was exactly my issue! Thank you!

Even I am stuck with this error. i am on Xcode 7.2.1. I did time profiling and i didnt not see any activity on main thread. All i have been trying is tap on button on App launch. Even i tried putting breakpoint just before the tap action to ensure Target App is done with work (with zero activity on main thead). Any other way to diagnose this issue?


This is what i have been getting

t = 11.25s Tap "OK" Button

t = 11.25s Wait for app to idle

t = 41.35s Assertion Failure: UI Testing Failure - App failed to quiesce within 30s

Thanks jos! It helps a lot!

I had the same issue, fortunately it was only related to one particular view which had a mess of refreshing calls to sort through. Here is the workaround I used:


For the view having issues and a line to disable animations in viewWillAppear:

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


and in viewWillDisappear turn animations back on:

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


In your tests extend XCUIApplication and set variables. Then in your setup method call that launchvariables function

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

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


func testblahblah {

This sets an environmental variable that will disable animations for that particualr view. Only downside is you won't be testing animations for that view if thats something your into. Hacky workaround but it works for now.

I am facing the exact same problem now. The testing code hangs because it thinks the view is not quiet, although it in fact is. The problem is this code:


  [UIView animateWithDuration:0.6 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction animations:^ {
  self.buttonFortune.center = CGPointMake(DEFAULTCENTER.x, DEFAULTCENTER.y + 3.0);
  } completion:^(BOOL finished) {
  self.buttonFortune.center = DEFAULTCENTER;
  }];


It's just an ever repeating thing to make the main button in the interface move slightly (to make it tap-appealing). I can't believe this is an issue that is not being addressed so far, lots of people must have run into to it and found it so far? I mean this thread is from 2015, and now we are close to 2017. It should be easy to reproduce from above code. Do I need to report a bug (or feature req)?


Note the use of the options above: UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionAllowUserInteraction


UIViewAnimationOptionRepeat is probably the "culprit" here which makes the UI testing wait forever... (or time out after a long time, 30 seconds?). With the use of the UIViewAnimationOptionAllowUserInteraction option at least, this whole thing should not be an issue (alas it is).



Update: I should add that in fact the tests still work, however they are still unfeasable because the "idle-wait" process goes on for something like 30 seconds or more, and THEN proceeds (successfully, if no other problem). So the tests eventually likely pass, but it just takes a very, very long time.

This just saved my bacon. HUGE find, thanks!

XCUITest
 
 
Q