fastlane/scan
fastlane/scan は fastlane シリーズの中でテストの実行を担当します。
fastlane シリーズはいろいろ触りましたが、一番単純でわかりやすいと思います。
何ができるか
いままで
コマンドラインで Xcode のテストを実行しようとすると以下のようなコマンドを打たねばなりません。
xcodebuild \
-workspace MyApp.xcworkspace \
-scheme "MyApp" \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1' \
test
人間が入力する文字ではないですね。
scan を使う
設定ファイル書いておくことで単に scan コマンドを実行するだけでテストを実行できます
bundle exec fastlane scan
使い方
Gemfile
gem 'fastlane'
bundle install --path vendor/bundle
します。
Scanfile
fastlane scan init
と打つと Scanfile のひな型が作成されるので、好きなように修正します。
私は以下のように書いています。
scheme "HogeTests"
configuration "Staging"
device "iPad Retina"
workspace "hoge.xcworkspace"
open_report true
clean true
skip_build true
output_types "html"
実行
bundle exec fastlane scan
でコンパイルとテストが実行され、テスト結果が表示されます
+--------------------+-----+
| Test Results |
+--------------------+-----+
| Number of tests | 224 |
| Number of failures | 0 |
+--------------------+-----+
便利機能
slack 連携
テスト実行するとこんな感じで連携される。
(ENV["SLACK_URL"] に webhook url は必要)
テスト結果の表示
output_types "html" でテスト結果がいい感じに見れます。
テストに要した時間も書かれていて良いですね。