What’s XCUITest, and why is it so important?

Fabio Soares
XCUITest
Published in
3 min readFeb 25, 2021

This is the first in a series of blog posts where I share what I’ve learned about XCUITest and how to get started with it.

Definition

XCUITest is a UI testing framework launched by Apple in 2015. With XCUITest, we can create automated tests for iOS apps using Swift.

In other words, if you want to create automated tests for native iOS apps, that’s the framework to use.

You might be wondering why you need to learn XCUITest, when there are so many mobile test automation frameworks available in the market. I hope the list below helps you understand why XCUITest is the best option when testing native iOS apps.

Pros of XCUITest

No need to install anything

It’s already prebuilt into Xcode, so basically, if you have Xcode, no need to install or download anything else.

Collaboration with developers

That’s exactly my experience. I did use Appium in the past, but in my case, being the only tester in the company and working with Ruby, the developers couldn’t really help me, and that meant there was no collaboration, which took me way longer to create anything, since I was learning by myself with no help.

Once iOS developers and Test Engineers use the same language to write code, there can be lots of collaboration, which can help both.

Speed

If you’re running pure XCUITest, that’s it. All other solutions have to run on top of XCUITest. We all know that UI tests are famous for taking a bit longer to run and everything, so pick the fastest option among them.

Test recorder

It’s pretty cool. The idea is that the Test Recorder captures everything you do on the simulator in code. This allows us to use that as a base, make some tweaks and tidy that up, so our tests are written in a better way.

Cons of XCUITest

No cross-platform testing

With XCUITest, you can’t write tests for multiple platforms. For example, you can’t have a test that is testing iOS and Android apps within the same test.

You’ll have to use Swift

You’ll have to use Swift. You can’t use your chosen language, like Java, Ruby or Python, with XCUITests, for example.

I reckon Swift is pretty cool to learn and use, so not really a downside for me.

And why is it important?

UI tests don’t fully replace manual testing, but they can help a lot with the heavy lifting. Every time there’s a new feature that could be breaking existing functionality, you’ll have to test it, and that’s where UI tests can help you. It helps you focus on the important stuff.

A good example of that at BNZ was that we used to take 3 or 4 days doing manual regression, we executed tests only on the last part of the release, and we’d always find bugs anyway, which was already too late.

With the help of UI tests being executed on PRs, tests were shifted left, the risk was shifted left and we could find issues that could impact the release way earlier.

Because of that we’re able to spend minimum time with manual regression, which has been given us a lot more confidence with the release.

Now that you’ve seen a bit of what XCUITest is, take a look at the second story of this series and learn about the most important XCUITest APIs.

The most important XCUITest APIs

Check my website for more content about testing, mobile, agile and much more! 👇👇👇

--

--