LoginSignup
12
9

More than 5 years have passed since last update.

fastlane/scan でテストを実行する

Posted at

fastlane/scan

scan\.png \(1759×652\)

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 コマンドを実行するだけでテストを実行できます :relaxed:

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 でコンパイルとテストが実行され、テスト結果が表示されます :tada:

+--------------------+-----+
|       Test Results       |
+--------------------+-----+
| Number of tests    | 224 |
| Number of failures | 0   |
+--------------------+-----+

便利機能

slack 連携

テスト実行するとこんな感じで連携される。
(ENV["SLACK_URL"] に webhook url は必要)

unspecified.png

テスト結果の表示

output_types "html" でテスト結果がいい感じに見れます。
テストに要した時間も書かれていて良いですね。

unspecified.png

カバレッジも出せる

iOS 開発での Pull Request と テストカバレッジの連携 // Speaker Deck

12
9
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
12
9