Frankとは
- cucumberで書いたテストをiOSアプリケーションに対して実行できるもの
- テストはRuby + cucumberで記述する
- テストはcucumberコマンドで実行する
テスト実装
環境構築
- 必要な環境はfrank-cucumberをインストールするだけ(勿論Rubyが書ける環境は必要)
-
$ sudo gem install frank-cucumber
でインストール
Frankのセットアップ
- iOSアプリケーションの.xcodeprojファイルが配置されているディレクトリまで移動する
- 以下を実行するとFrankディレクトリが作成される
$ frank setup
create Frank
create Frank/features/my_first.feature
create Frank/features/step_definitions/launch_steps.rb
create Frank/features/support/env.rb
・
・(長いので途中は省略)
・
It appears that your 'Debug' configuration's OTHER_LDFLAGS build
setting already include some FRANK setup. Namely: ["$(inherited)",
"-lsqlite3.0", "$(FRANK_LDFLAGS)"]. I won't change anything here.
It appears that your 'Debug' configuration's LIBRARY_SEARCH_PATHS
build setting already include some FRANK setup. Namely: ["$(inherited)",
"\"$(SDKROOT)/usr/lib/system\"", "$(FRANK_LIBRARY_SEARCH_PATHS)"].
I won't change anything here.
- .xcodeprojファイルが配置されているディレクトリに移動していなければ、「There are no .xcodeproj files in this directory. Please move to your root project directory and try again.」と怒られる
ビルド
- 以下を実行すると、ビルドが実行される
- 最後にBUILD SUCCEEDEDとなっていることを確認する
$ frank build
remove Frank/frankified_build
run xcodebuild -xcconfig Frank/frankify.xcconfig clean build
-arch i386 -configuration Debug -sdk iphonesimulator
DEPLOYMENT_LOCATION=YES
・
・(長いので途中は省略)
・
** BUILD SUCCEEDED **
run /usr/libexec/PlistBuddy -c 'Set :CFBundleIdentifier jp.co.jrits.APE.frankified' Info.plist from "./Frank/frankified_build/Frankified.app"
run /usr/libex
サンプルテストの実行
- frank setup時に生成されるサンプルのテストを動かしてみる
- このサンプルはアプリ起動するテスト
$ cucumber features/my_first.feature
Feature:
As an iOS developer
I want to have a sample feature file
So I can see what my next step is in the wonderful world of Frank/Cucumber testing
Scenario: # features/my_first.feature:6
Rotating the simulator for demonstration purposes
Given I launch the app # features/step_definitions/launch_steps.rb:5
Given the device is in landscape orientation # frank-cucumber-1.1.8/lib/frank-cucumber/core_frank_steps.rb:151
Given the device is in portrait orientation # frank-cucumber-1.1.8/lib/frank-cucumber/core_frank_steps.rb:151
Given the device is in landscape orientation # frank-cucumber-1.1.8/lib/frank-cucumber/core_frank_steps.rb:151
Given the device is in portrait orientation # frank-cucumber-1.1.8/lib/frank-cucumber/core_frank_steps.rb:151
1 scenario (1 passed)
5 steps (5 passed)
0m4.311s
シミュレータ起動
- frank launchを実行するとシミュレータが起動する
- http://localhost:37265にアクセスすると、要素の一覧が閲覧できる
$ frank launch
LAUNCHING IN THE SIMULATOR...
テスト作成
- frank setup時に生成されたFrankディレクトリ下のfeatures下にxxx.feature/xxx_steps.rbファイルを配置する(cucumberの書き方については割愛)
- テスト実行方法は前述した サンプルテストの実行 と同じ
参考になるサイト
* http://testingwithfrank.com/
* http://blog.thepete.net/blog/2012/06/24/writing-your-first-frank-test/
* http://www.slideshare.net/numeha/ios-17676435
* http://rubydoc.info/gems/frank-cucumber/0.6.1/Frank/Cucumber/FrankHelper
~ただの宣伝~
- 全国のSeleniumer必読
- Seleniumerといっていますが、Selenium, SauceLabs, Travis, Jenkinsに関するノウハウ書いているのでよかったら参考にしてみてください