Laser Hawk
Laser Hawk

Reputation: 2028

XCTest in Swift 2.3 painfully slow

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?

Upvotes: 0

Views: 477

Answers (1)

Oletha
Oletha

Reputation: 7659

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.

Upvotes: 1

Related Questions