事の発端
M1 Mac mini性能いいしビルドめっちゃ早くなるじゃん!!!
↓
ただメモリ少ないし大食いChromeのおかげでスワップ入りまくって快適じゃない...
↓
メイン開発機にはスペック不足だけど置いとくのももったいない...
↓
なんかIntegration testいい感じにアップデートされたっぽいしやってみるか
↓ テスト実行に毎回ビルド必要っぽいしトライアンドエラー時間かかるなぁ ↓ テストだけMac miniで回せばよくない? ← いまここ🎉 Announcing version 1.0 of the integration_test plugin, a simpler way to test your Flutter apps that also supports @Firebase Test Lab. Learn more on...
— Flutter (@FlutterDev) December 9, 2020
✅ Running on Firebase Test Lab
✅ Migrating from Flutter driver tests
✅ Native UI testing
Read → https://t.co/pZIDL3V2Ix pic.twitter.com/BXeqJRcbKd
(M1である必要性は全くない)
動作概要
結局はrsyncで必要そうなファイルを同期してテスト実行するだけ。
スクリプト書いた sync_and_test.sh
同期元と同期先のディレクトリを指定して、実行するテストを指定する
(テストを実行したいマシン(本記事ではM1 Mac mini)にsshして実行する)
プロジェクト自体はgit clone済みで、よく変更するかもしれないファイルだけを同期する形
Flavorなどを渡したい場合はflutter drive
でも--dart-define
が使える
# !/bin/bash -eu
if [ $# -ne 3 ]; then
echo "e.g. ./sync_and_test.sh from/path to/path target_test_dart" 1>&2
echo "e.g. ./sync_and_test.sh your-mac.local:~/Develop/projectA/ projectA splash_page_test.dart" 1>&2
exit 1
fi
rsync -ahv --progress \
--exclude='.DS_Store' \
--include='lib/**' \
--include='assets/**' \
--include='scripts/**' \
--include='test/**' \
--include='integration_test/**' \
--include='test_driver/**' \
--include='pubspec.yaml' \
--include='pubspec.lock' \
--exclude='android' \
--exclude='ios' \
--exclude='build' \
--exclude='*.*' \
$1 $2
APP_NAME=アプリの名前
APP_SUFFIX=.dev
APP_ENV=dev
( \
cd $2 && \
flutter drive \
--dart-define APP_NAME=$APP_NAME \
--dart-define APP_SUFFIX=$APP_SUFFIX \
--dart-define APP_ENV=$APP_ENV \
--driver=test_driver/integration_test_driver.dart \
--target=integration_test/$3 \
)