KIF is iOS UI Test Library made by Square(GitHub kif-frameworks)

Compare to iOS UI Automation with Instruments, we can write Test code using Objective-C.
You can write test with SenTestKit(Old) and XCTest. It means you use both logic and UI tests.
* As KIF author mentioned, KIF includes private API, so don’t include App compile targets. We should use only test target.

How to use

Original code is static library style.
You can download from Git.(use git or download as zip)
Other people explains how to download with git, so I explain how to use codes itself.

Copy source codes

Code source codes under KIF group
KIF/Additions, KIF/Classes are core codes, please copy them.

KIF Projet

* Careful *
If you want to copy source codes on your test, you need some changes
Especially, you use XCode6 above, Precompile header is not required, so you need change for it.


If you don’t use Precompile header, you add header import in KIFTypist.h

#import <Foundation/Foundation.h>
@interface KIFTypist : NSObject

Add first line #import
KIF is originally static library so, you need to change for it.

#import "KIF.h"

Original code is

Source compile should be fine. Let’s start Test.

With Unit Test

Key point is touch, wait, …
As example, write small
To find UI and touch, accessibilityLabel is useful for KIF.
accessibilityLabel is name we can add to UI.


In Interfacebuilder, you can add it as property.
In code

UIButton *button = [UIButton alloc] init];
button.accessibilityLabel = @"button1";

button1 is label.

Test Sample

This is sample

#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import "KIF.h"

@interface KIFSample_Tests : KIFTestCase


@implementation KIFSample_Tests

- (void)testClick {
  [tester tapScreenAtPoint:CGPointMake(20, 20)];  // Touch left-top point
  [tester tapViewWithAccessibilityLabel:@"buttonA"]; // buttonA label


This is simple test example. tester is macro in KIF.h
Only tap left top position.
We can use XCTAssert series.


There are some useful methods


We can find touch place point or accessibilityLabel

[tester tapScreenAtPoint:CGPointMake(20, 20)];
[tester tapViewWithAccessibilityLabel:@"buttonA"];

The point is calculated in methods. Please look at source codes.


Only wait(s)

[tester waitForTimeInterval:3];

Wait until UI item disappear using accessibilityLabel

[tester waitForAbsenceOfViewWithAccessibilityLabel:@"buttonA"];


Fill textfield

[tester enterText:@"jookoon" intoViewWithAccessibilityLabel:@"username"];

How to get current UIViewController

UIViewController *currentController = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;