Hi everyone. Welcome to the Test Automation University course on XCUITest. Before we jump into the hands-on course, let's go through a few slides and get ourselves familiar with XCUITest.
XCUITest is a UI testing framework launched by Apple in 2015. With XCUITest, we can test user interface or Apple platform apps using Swift or Objective-C programming language.
XCUITest will only work with the native apps written in Swift or Objective-C, which means, we cannot use XCUITest to test cross-background apps, like React Native, Flutter, or Cordova apps. If you want to know more about XCUITest, I would strongly recommend you watch this WWDC (World Wide Developers Conference) video that covers XCUITest from basic to the advanced level.
UI Testing in Xcode - Xcode 7 introduces new UI testing features fully integrated into the IDE. Learn about the new APIs and how UI testing fits in with existing testing features in Xcode. See how to get started by recording your app, and how to efficiently craft and maintain UI tests.
If you want to get into XCUITest, you may also want to learn Swift, because XCUITest uses Swift for writing UI, network, and performance tests. Swift is a modern, fast, type safe, and most importantly, it's an easy to learn programming language. With Swift and XCUITest, you can automate Apple platform apps very easy.
You might be wondering why you need to learn XCUITest, when there are so many mobile test automation frameworks available in the market. It's because XCUITest is native, and, by being native it is superfast. And, all of the mobile test frameworks use XCUITest under the hood.
If you use XCUITest to automate your iOS apps or other Apple platform apps, you might be using Swift to write your test, which is a very similar stack to what your developers are using — which increases the collaboration between app developers and automation engineers writing XCUITest.
Another benefit of having XCUITest is your XCUITest pipeline becomes so painless, as XCUITest can be integrated into your pipelines, just like unit tests. If you want to use XCUITest, you need to improve accessibility of your apps because XCUITest works with your apps using accessibility technology.
There are a few downsides to XCUITest though. With XCUITest, you cannot write tests for multiple platforms. Like, you cannot have a test which is testing iOS and Android apps within same test.
Another thing is if you want to use XCUITest, you might have to use either Swift or Objective-C as a programming language. You cannot use a language of your choice, like Java, Ruby, Python, or C# with XCUITest.
Let's talk about XCTest
XCTest is a general testing framework, used for unit integration, network, or performance testing of Apple platform apps. With XCTest you can treat it as an xUnit type of test framework, which can be used for lower-level testing.
The XCUITest framework is an extension to the XC test framework but there are some basic differences between XCTest and XCUITest framework.
XCTest framework is a completely white-box framework where you can access the data and API in your main app.
However, the XCUITest is completely black-box to your app, so you cannot access the data or API of your main app.
The only communication you can get from XCUITest to main app is using Launch Argument and Launch Environment. We will cover this in detail when we actually write this XCUITest, in the later chapters.