Automated UI Testing in iOS – is it the Future of App Testing!

Automated UI Testing in iOS – is it the Future of App Testing!

Automated UI Testing
3 Minutes Read

“Quality is never an accident; it is always the result of intelligent effort.” – John Ruskin

Sir John Ruskin did taught us a very important lesson in the line of testing. Though, we think testing is a manual process of careful study and intelligent analysis. Time is moving faster than we can think and so is the testing procedures.

Automated UI testing is the new key for iOS app examinations. Moreover, this is going to change the entire methodology of iOS App Development Process.

You probably heard about automated testing before. Nowadays, people are talking a lot about automated testing especially when it comes to app and product quality.

It’s always a big challenge for developers to make the app or a product bug free and improve its overall quality. Studying and analyzing the test cases for the projects are highly important and you might get into big trouble(which we do not want at all) if you will not write the tests of your projects. If not immediately (or at that moment), you may get affected in future in the long run.

Today in this article, I am going to enlighten you the different ways you can test your iOS app or a product as well as guide you in writing Automation UI Tests for your apps.

Normally, testing is divided into two categories – Manual Testing and Automation Testing.

Manual testing is the process to test your app or product manually and I’m sure everyone has a good knowledge about manual testing and I don’t want to waste your time telling you details on this.

So, let us get started with Automated Testing in IOS;

Generally, Automated Tests are two types in iOS

  1. Unit Test (Test of specific case in the class)
  2. UI Test or Integration Test (individual modules or testing of groups)

Before telling the process how to write automated UI tests for our app, you might be thinking that why you should automated UI tests for your product or app?

Let’s have look at the key benefits automated UI tests below.

  • To minimize time spent on manual testing.
  • To avoid regression bugs. If you are changing something in the code then you must test it again to check whether it doesn’t break anything and the app is still works as expected.
  • It helps to document our code.
  • It provides visual run – through our app.

What is UI Testing?

UI test is composed of actions that a user can take. It’s like a step-by-step guide with some expectations along the way.

Let’s have a look at the common format with example

Do something

Expect something to happen


Pull to refresh

We can see new things on the top

How to write UI Test?

First of all we need a framework called KIF- Keep It Functional (An iOS integration test framework which allows for easy automation of iOS apps and performs the tests using a standard XCTest testing target), which offers a whole lot of APIs to deal with UI interactions.

For Example:

Example to fill some text in the text field:

[code language=”html”]
tester().enterTheText("some text", intoViewWithAccessibilityLabel: "textfield name")

Here,accessibility label is a name you give for each UIView to distinguish among them.

How to setup KIF for UI Testing?

Step 1:

Import KIF and Nimble

Nimble is a framework to help you to express your expectation in test.

[code language=”html”]
pod ‘KIF’

pod ‘Nimble’

Step 2:

Create KIF Helper

Step 3:

Create Bridging Header

Step 4:

Create our UI Test

Create new file in the test target.

Then import KIF

Note: 1) your test must be a subclass of KIFTestCase
2) Test methods must begin with the word test

For example test the login screen with empty username and password.

[code language=”html”]
Scenario: Empty username and password

Given I clear out the username and password fields

When I click"Login" button

Then I expect to see alert "Username cannot be empty"

functestForBlankUsernameAndPassword() {



expectedAlert("Username cannot beleft blank")



funcclearOutUsernameAndPasswordFields() {

tester().clearTextFromViewWithAccessibilityLabel("Login – Username")

tester().clearTextFromViewWithAccessibilityLabel("Login – Password")


funcclickedButton(buttonName: String) {



funcexpectedAlert(text: String) {



Now we can run our test by pressing cmd + U. The simulator will pop up and run over your steps automatically.

Finale – in the end

UI test is easy to learn but it gives many benefits to us. By this, you can cover all your scenarios and functionalities as a user. It will help you to save time and make the coding funnier.

Jayadev Das

Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘bout Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

No Comments

Post A Comment

Exit pop up

Sad to see you leaving early...

From "Aha" to "Oh shit" we are sharing everything on our journey.
Enter your email address to stay up to date with the latest news.
Holler Box