Did you know that the total number of iOS devices sold in the
market is 250 Million+?
11% of the iOS users remove the app after crashes
45% of iOS users would remove the paid apps after crashes
69% of iOS users would will stop playing and remove the games after first crash
6-7 iOS devices are sold every second
With the explosion of iOS devices year on year, the verge of iOS success is increasing higher than ever before. More start-ups and SMEs don’t find it financially sustainable to acquire every piece of iOS devices with different OS versions and hardware specs. On the other hand, testing apps or games manually is not anymore an ideal option for QA process due to low efficiency and scalability issue.
Though iOS is still a more closed operating system compared to Android, many open source test automation frameworks and tools can be utilized to create robust automated tests. Along with the help of a cloud-based testing solution, it enables developers/testers to verify app quality more efficient in a scalable way and makes iOS testing tasks easier.
Today we’d like to go through 5 widely used iOS testing frameworks nowadays with simple code samples to give you a basic understanding of getting started with your iOS testing. If you are also interested in Android test automation frameworks, do not forget to check out Top 5 Android Testing Frameworks, where code samples are provided as well.
Appium is popular due to its flexibility and usability on both Android and iOS, and it works on native, hybrid and web applications. For iOS testing, it uses JSONWireProtocol to engage with iOS applications using Selenium WebDriver. Thanks for that, Appium does support mobile web testing very well and its use cases are very similar as if Selenium would be used for web testing.
APPIUM CODE SAMPLE
XCTEST / KIF
XCTest is tightly coupled with Xcode but is still usable with both real iOS devices and simulators. XCTest allows developers to write tests for components at any level and also provides the framework for UI testing capabilities. XCTest tests are grouped into subclasses of XCTestCase. Writing any tests with XCTest should be trivial to iOS developers as XCTest is fully compatible with both Objective-C and Swift.
KIF (Keep It Functional) is an iOS integration test framework that is closely related to and uses XCTest test targets. KIF tests can be executed directly in XCTestCase or any subclass. KIF allows for easy automation of iOS applications by leveraging the accessibility attributes that the OS system makes available for those with visual disabilities.
CODE SAMPLE WITH OBJECTIVE-C
CODE SAMPLE WITH SWIFT
Learn and get started with KIF by reading our blog about this: How to get started with KIF?
Calabash is another great cross-platform framework that works perfectly with Android and iOS apps. One of the major differences to other frameworks is that Calabash tests are written in Cucumber. That means the test is written like a specification and is simple and easy to read even for non-tech people, but still executable by the automation system.
CALABASH CODE SAMPLE
To some degree, EarlGrey is the ‘Espresso for iOS’. It’s also developed and open sourced by Google. Google uses this test framework to test many iOS native apps including Google Calendar, YouTube, etc. As the codename goes, lots of similarities can be found between Espresso and EarlGrey. For example, EarlGrey tests will automatically wait for events (animations, network requests etc.) before trying to interact with the UI.
EARLGREY CODE SAMPLE
JEST / JASMINE
JASMINE CODE SAMPLE
BONUS: UI AUTOMATION
NOTE! UI Automation still works fine if you are some using older version of Xcode, but with the latest Xcode, the entire UI Automation framework is deprecated by Apple.
UI AUTOMATION CODE SAMPLE
Though iOS app testing is totally different from Android app testing, you can use either Appium or Calabash to create test scripts that can be used to do cross-platform testing. That being said, every framework has its advantages and requirements are unique for each project. It’s recommended to do some further research, learn more about each framework and choose the one you are comfortable with. Happy iOS testing.