iOS Unit Testing and UI Testing Tutorial |

Learn how to add unit tests and UI tests to your iOS apps, and how you can check on your code coverage.

This is a companion discussion topic for the original entry at

Thanks. If anyone’s interested in adding visual UI testing for their iOS apps, this tutorial explains how to do so:

(Disclaimer: this is for a commercial product called Applitools, where I work.)

1 Like

Thanks for this great and interesting tutorial.

However, I’d like to know if XCUITEST can be used to check some VoiceOver implementations including custom actions to be fired.
I’m not sure this is possible because I understood that only elements on screen are reachable… and that’s definitely not the case with custom accessibility elements and custom actions.

Could you give me your point of view about XCUITEST and VoiceOver, please ?
Thanks in advance for your return.

@mkatz Can you please help with this when you get a chance? Thank you - much appreciated! :]

I’m not sure that you can, but maybe someone in the official forums knows. If you do find out, please update us here.

In our apps we use view models so we have unit tests on the view models that check for the custom a11y elements. This is backed up by manual testing of voiceOver.

I’m currently making a buyback business and use mobile device diagnostic software for testing and it is a really worthy application.

Hi everyone, (answer for mkatz)

During the WWDC 2019 WWDC19 Accessibility and Testing Labs, the Apple engineers said that the reason why accessibility is not available during UI testing are security concerns: that’s definitely not possible right now unfortunately.

I’m confused where we got the 90 from so 90+5=95?

hi Jason! sorry, I’ve been offline for 10 days.

It’s not that 90+5 = 95. The test sets the guess value to 5 more than whatever the (random number) target value is. This means the guess is always off by 5 so, If the score calculation is correct, the score should be 100 - 5 = 95.


Thanks for such a great tutorial.
However I was little bit confused and felt that in starting of the tutorial if more coverage is given on functions called from tests than it could give more clarity. Writing test over already created project, it is somewhat hard to grab.

hi Deepanshu! there’s a really interesting approach called test-driven development — start with this tutorial, then maybe look at our book.

Hi, on the 3rd test HalfTunesFakeTests.swift, getting the path is returning nil. I believe it’s because the test bundle path is incorrect but I’m not sure what’s incorrect as it’s exactly the same as the tutorial. Any help?

@mkatz Do you have any feedback about this? Thank you - much appreciated! :]

hi Dustin! sorry, I didn’t see this earlier.

I just downloaded the materials and the test ran OK. Check your files, maybe you need to download again. Here’s what I have:

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!