LoginSignup
1
1

More than 5 years have passed since last update.

KIFのメモ

Last updated at Posted at 2015-05-17

ひょんなことから,Squareが開発しているテストフレームワークKIFについて調べたのでまとめておく.Qiitaやその他WEBに,KIF Ver.1系の話とVer.2系以降の話が混じっていてややこしい.

概要

推奨利用者

  • UI ObjectにAccessibility Labelが設定されていて,開発者自身がテストをする際には,有用と思われる.
    • データ駆動やBDDが容易だがテストコードではあるため,非開発者が利用する際には変換処理系の開発が必要

詳細情報

  • iOS向け Integration Testing Framework OSS
    • https://github.com/kif-framework/KIF
    • 2015/06/28時点で,Ver. 3.2.3
      • Ver.1系と Ver.2系でAPIや動作が大きく変化している
        • WEBで検索されるものはVer.1系が交じるので注意が必要
  • 開発元
    • 決済サービスを開発している Square が主として開発している
  • ライセンス
    • Apache License Ver 2.0

特徴(開発元ページより)

  • Minimizes Indirection
  • Easy Configuration
  • Wide OS coverage
  • Test Like a User
  • Automatic Integration with Xcode 5 Testing Tools

Minimizes Indirection

All of the tests for KIF are written in Objective C. This allows for maximum integration with your code while minimizing the number of layers you have to build.

  • テスト記述言語
    • Objective-C もしくは Swift
      • Swiftの場合は若干細工が必要だが,細工の方法は公式ページで記載されている

Easy Configuration

KIF integrates directly into your Xcode project, so there's no need to run an additional web server or install any additional packages.

  • インストール方法
    • CocoaPods もしくは GitHubからダウンロード
    • testing target 作成推奨
      • 理由は注意点参照
      • (既存でtesting bundle targetがある場合は,修正)

Wide OS coverage

KIF's test suite has been run against iOS 5.1 and above (including iOS 8), though lower versions will likely work.

Test Like a User

KIF attempts to imitate actual user input. Automation is done using tap events wherever possible.

  • テスト記述方式
    • KIF は "Actor""その操作" を手続きとして記述していく
    • 操作はデフォルトでだいぶ用意されているが,自分でも定義できる
      • 開発者によるBDDが実現可能
    • ソースコード例("Tap"というラベルが付けられたオブジェクトをタップする)
      • [tester tapViewWithAccessibilityLabel:@"Tap" ];

Automatic Integration with Xcode 5 Testing Tools

Xcode 5 introduces new testing and continuous integration tools built on the same testing platform as KIF. You can easily run a single KIF test with the Test Navigator or kick off nightly acceptance tests with Bots.

  • ツール構成
    • KIFのテストケースはXCTestを拡張する形で動作し,アプリ操作の部分を容易化している.
      • 実行はXCTestとUI Automationを用い,評価はXCTestを用いる.
        • 一応XCTestのAssertメソッドを再定義する形でAssertメソッドは存在するが,現時点では独自のものは存在しない
      • KIF記述によるテストケース-KIFフレームワーク-[XCTest, UI Automation]-Test Target App.
  • 実行
    • 基本的には,XCodeのtesting targetでの実行
    • シミュレーターでも実機でも実行可能
      • XCodeの実行先として選択

注意点

  • 操作するUI Objectのaccessibility Labelが設定されていないと操作できない
    • 画面のある座標のタップやスクリーンショットは除く.
    • OSによるオブジェクトの任意のテキストをLabelとみなす機能により,Labelが明に設定されてなくても動作することはある.
  • Apple非認証のAPIを利用しているので,テストを含む形でアップロードはできない.
  • (原因不明) ターゲットアプリがインストールされている状態で,実行するとXCodeが落ちることがある.

その他

  • 操作のレコーディングや操作しているUI Objectの情報などを取得するツールは存在しない.
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1