0

I am responsible for iOS automation at my company and I am working with Swift in XCTest. My company is in the midst of converting to Swift 3 and in the interim I've converted my tests to Swift 2.3 until we've completed the conversion. The automation has slowed to an unacceptable speed. So bad that if we were at the beginning again and choosing frameworks XCTest would have been disqualified. My test times have gone up by almost a third in this transitional swift conversion. Trying to uncover what the issue was this link was helpful: Swift 3 Compile Time Incredibly Slow

We applied final to all class models to deal with lazy vars which gained us 6 seconds per test! Unfortunately that doesn't bring it back to its original speed :(

As those of us in the mobile automation world know using NSPredicate as recommended by @Joe Masilotti is the best way to wait for elements https://stackoverflow.com/users/384110/joe-masilotti

I commented out a test that used a custom func waitForElement () that included let existsPredicate = NSPredicate(format: "exists == true"). The same test now gained an additional 3 seconds! So a total of 9 seconds is substantial, but unfortunately this is still not back to the original speed. I hope that expresses my words on how slow swift 2.3 has become.

I am going to trying to convert only the test targets to swift 3 and see if that helps. My theory on that is Xcode 8 is optimized for swift 3 not swift 2.3

My question is, is there another way to write NSpredicate / waitForElement or hittable method in an extension that would not slow down my tests?

Community
  • 1
  • 1
Laser Hawk
  • 1,988
  • 2
  • 23
  • 29
  • 1
    Are you sure this isn't because you are running against iOS 10 simulators since you updated to Xcode 8? In my experience, the iOS 10 simulators run a lot slower than the iOS 9 ones. – Oletha Oct 19 '16 at 21:48
  • interesting I'll try that, and yes I am running a 10 sim. – Laser Hawk Oct 19 '16 at 22:01
  • Holy crap that took a test that from a 120 seconds in an OS 10 sim to 55 seconds in a OS 9 sim. Thank you for the tip. Cant believe Apple released Swift 3 like that. If code that goes slower is a goal of theirs, then they hit a milestone. Congrats Apple let me know if you need QA. – Laser Hawk Oct 26 '16 at 00:51

1 Answers1

1

The iOS 10 simulator is significantly more resource-intensive than the iOS 9 simulator was.

If you want to run your tests faster, switch to the iOS 9 simulator, however you will need to put up with the slower tests in order to test on the current version of iOS.

Make sure you have a high-spec Mac as your CI server - people often make the mistake of using a base-spec Mac Mini, which is terribly slow at running tests. More power can help a lot.

Oletha
  • 7,324
  • 1
  • 26
  • 46