Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AWS Device FarmとCircleCIでAndroidのUIテストを自動化しよう
Search
Fumihiko Shiroyama
December 16, 2019
Technology
1
4.9k
AWS Device FarmとCircleCIでAndroidのUIテストを自動化しよう
AWS Device FarmとCircleCIでAndroidのUIテストを自動化しよう
Fumihiko Shiroyama
December 16, 2019
Tweet
Share
More Decks by Fumihiko Shiroyama
See All by Fumihiko Shiroyama
The world of Android wireless communications without Internet
srym
1
120
Spring BootをKotlinで作成しAmazon Elastic Container Service (ECS) で稼働させる
srym
6
1.9k
iOSDC_2019_DeviceFarm.pdf
srym
8
19k
世界で戦うエンジニアになるために_公開用.pdf
srym
18
45k
Unit Testing in a Nutshell - DroidKaigi 2018
srym
11
15k
Clean Architecture & TDD
srym
1
3.7k
はやい・やすい・うまい!スタートアップでも使える Retrofit + RxJava で瞬間APIクッキングレシピ
srym
2
580
I/O 2017 Short Report
srym
0
300
Mock Partially using Dagger
srym
0
640
Other Decks in Technology
See All in Technology
最新のWasm事情
askua
5
2.6k
生成AIの活用パターンと継続的評価
asei
6
660
AIとともに歩んだライブラリアップデートの道のり/ vue-fes-japan-2024-link-and-motivation
lmi
2
2.5k
Demystifying Vite Internals
nozomuikuta
3
920
XSS攻撃から考察するAWS設定不備の恐怖/20241012 Hironobu Otaki
shift_evolve
0
180
次は君だ。~Japan AWS Jr. Champions 受賞までの奇跡~
fukuchiiinu
0
190
暴カワでビデオシンセサイザーを導入する技術
yuchi
2
130
生成AI入門
shukob
0
170
全社を巻き込んだ業務オペレーション改善と、それは事業成長に貢献しているのか?を実感した話
marroooon
0
160
いまいまMySQL2024 @ OSC Nagaoka
sakaik
3
310
Brakeman を欺く - Kashiwa.rb #4
kozy4324
1
110
VueとViteで作るUIコンポーネントライブラリ ~デザインシステムとプロダクトの理想的な分離を目指して~ / 20241019_cloudsign_VueFesJapan2024_1
bengo4com
8
4.9k
Featured
See All Featured
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
225
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Practical Orchestrator
shlominoach
186
10k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
KATA
mclloyd
29
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Rails Girls Zürich Keynote
gr2m
93
13k
Typedesign – Prime Four
hannesfritz
39
2.4k
Six Lessons from altMBA
skipperchong
26
3.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Transcript
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Application Prototyping Solutions Architect Fumihiko Shiroyama December 16, 2019 AWS Device FarmとCircleCIで AndroidのUIテストを⾃動化しよう Android/iOS Test Night 2019
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. ⾃⼰紹介 名前:⽩⼭ ⽂彦(しろやま ふみひこ) 所属:アマゾン ウェブ サービス ジャパン株式会社 アプリケーションプロトタイピングソリューションアーキテクト 経歴:インフラエンジニア、バックエンド開発者 モバイルアプリ開発者、クラウドアーキテクト 趣味:⼦育て!、懸垂、⾃動テスト#
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. ⾃動テスト⼤好きです! • Androidテスト全書という本を出しました • ⾃動テストの種類やそれぞれがカバーする範 囲、モック(テストダブル)の考え⽅、UIテ スト、CI/CDとの統合など、Androidにおけ るテストについてひと通りカバーされた本で す
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. アジェンダ 本セッションのゴール • AWS Device Farmでノーテストでバグを⾒つける • AWS Device Farmで任意のバージョンの端末にリモートアクセス • AWS Device FarmでUIテストを⾃動実⾏ • CircleCIからAWS Device Farmを利⽤する • CI/CDとSlackを連携する
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 対象となるアプリ
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. ゴリラ CHANGE
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. ゴリラ CHANGE
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. デモ
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 特定のバージョンのバグを⾒つけ出す
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. リリースしたが… なんか私のGalaxy S6(Android 6) でクラッシュするんですが… 弱ったな… こちらで確認できないぞ
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. バグの事実と原因を確かめたい • ユーザからAndroid 6系で動かないという報告があった • 実はAndroid 6以下でクラッシュする深刻なバグがある • 報告を確かめたいが古い端末は⼿元にない • AWS Device Farmを使ってみよう(
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS Device Farm
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 近年のモバイル開発が抱える課題 デバイスとOSの 多様化 複数のテストフレー ムワーク対応の困難 デバイスメンテ の⼿間 テストレポートの 可視化に対する要望
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS Device Farm ⾃動テスト リモートアクセス ⾃動テストを好きな時に 好きな数だけクラウド上 で並列実⾏ クラウド上の好きな端末の 任意のバージョンですぐに リモートで動作確認
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 様々なテストパターンに対応 アプリ UI Automation UI Automator XCTest 各種テストフレームワーク AWS Device Farm 詳細なレポート
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. デバイスタイプ • パブリックデバイス • 0.17USD∕デバイス分の従量課⾦(無料利⽤期間1000デバイス分あり) • 250USD∕⽉の定額プランで無制限利⽤ • 端末はテスト毎にデータ消去して再起動 • プライベートデバイス • 200USD∕⽉から利⽤できる専有デバイス※1※2 • デバイスは専有で決して他者と共有されず、契約終了後に廃棄 ※1 端末の取得価格によって変動 ※2 最低6ヶ⽉の利⽤など諸条件あり
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 早速使ってみよう
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Built-in: Fuzzテスト • いわゆるモンキーテスト • テストコードがなくてもUIをランダムに操作して落ちないか確認 • 複数のデバイスやOSを並列実⾏できる
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. apkをビルド ./gradlew :app:assembleDebug
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS Device Farm プロジェクトの作成
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Automated Tests apkのアップロード ⾃動テストを選択
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Automated Tests テストするデバイス群 Fuzzテスト Device poolの選択
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Fuzzテスト テスト結果 やはり古いバージョンで エラーが起こっているようだ
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Fuzzテスト テスト結果
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. エラーの録画を確認する
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 正常系
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 異常系
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Screenshots 正常系 異常系
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Screenshots 正常系 異常系
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Logs
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. リモートアクセス
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. リモートアクセス ⽬当ての端末選択 リモートアクセス
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. リモートアクセス ブラウザから操作
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. リモートアクセス アップロードして 実際に試すことができる
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. その他のテスト
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. その他のテストをAWS Device Farmで実⾏する • AWS Device FarmはFuzzテスト以外にも多数のテストをサポートしている • Instrumentationを選ぶことでUIテスト(Espresso)が実⾏できる • 他にもAppiumやUI Automatorなど多数のフレームワークをサポートしている
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentation (Espresso)
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentation (Espresso) • https://docs.aws.amazon.com/ja_jp/devicefarm/latest/developerguide/test- types-android-instrumentation.html 1. ⼿順を参考にアプリ本体のapkをビルドする(assembleDebug) 2. ⼿順を参考にUIテストのapkをビルドする(assembleDebugAndroidTest) 3. AWS Device Farmにアップロードして実⾏
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentation (Espresso) • https://docs.aws.amazon.com/ja_jp/devicefarm/latest/developerguide/test- types-android-instrumentation.html 1. ⼿順を参考にアプリ本体のapkをビルドする(assembleDebug) 2. ⼿順を参考にUIテストのapkをビルドする(assembleDebugAndroidTest) 3. AWS Device Farmにアップロードして実⾏
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentationテスト テストapkをアップロード
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentationテスト ⽤途に応じて独⾃のDevice Poolも定義できる Deviceの台数や組み合わせも任意
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentationテスト 追加のオプションや タイムアウトを設定して実⾏
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentationテスト
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Instrumentationテスト
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CI/CDとの統合
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CI/CDとの統合 • AWS Device Farmは便利だが⼿動でアップロードは⼤変 • CI/CDツールと連携することで⽇々のテストを⾃動化できる • ここではCircleCIを使ってDevice Farmのテストを⾃動化する • https://circleci.com/
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIとの連携 macOSでビルドするには有料プランが必要(無料トライアルあり)
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIの設定 • プロジェクト直下に.circleci/config.ymlという設定ファイルを設置 • yamlファイルを編集しビルドとテストの実⾏を設定(後述) • Gitレポジトリへのプッシュを契機にビルドとテストが開始される • 基本はGradleのコマンドを記述するだけ
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. aws-device-farm-gradle-plugin • https://github.com/awslabs/aws-device-farm-gradle-plugin • Gradle plugin for AWS Device Farm • apkのビルド、アップロード、テストの実⾏などを⼿助けするプラグイン • DSLで細かい設定が可能
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Project build.gradle • classpath 'com.amazonaws:aws-devicefarm-gradle-plugin:1.3’
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. App build.gradle • apply plugin: 'devicefarm’ • devicefarm{ 各種設定 } • ./gradlew devicefarmUpload projectNameは Device Farmの設定に合わせる
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. App build.gradle • apply plugin: 'devicefarm’ • devicefarm{ 各種設定 } • ./gradlew devicefarmUpload IAMユーザと権限は最⼩に!
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIへの組み込み • 基本はGradleコマンドを列挙するだけ • ./gradlew :app:assembleDebug • ./gradlew :app:assembleDebugAndroidTest • ./gradlew :app:devicefarmUpload
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIの環境変数設定
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIの環境変数設定
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. • https://slack.com/services/new/incoming-webhook Slackに通知
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIの環境変数設定
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Slackに通知
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 満を持してプッシュ!
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIコンソール
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIコンソール
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Device Farmコンソール
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCI Workflow • すべてのプッシュでDevice Farm連携したくないケース • Workflow機能を使ってmaster/releaseブランチプッシュ時だけ Device FarmでUIテストを実⾏するといった制御が可能 • https://circleci.com/docs/ja/2.0/workflows/
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved.
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved.
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 処理の流れおさらい 1. Gitレポジトリへのプッシュを契機にCircleCIでビルドが始まる 2. 通常のGradleコマンドでapkをビルド 3. ワークフローでmasterブランチだけDevice Farmが⾛る 4. aws-device-farm-gradle-pluginプラグインがDevice Farmにアップロード 5. 結果をCircleCIに通知する
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. CircleCIコンソール masterだけ UIテスト
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Yay!!!
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. ご清聴ありがとございました,
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. 質疑応答
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Appendix
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. スライドURL http://bit.ly/34iYRc4
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. AWS Device Farm テストデバイス⼀覧 • Q. AWS Device Farmではどのようなデバイスが利⽤できますか • A. モバイルアプリケーションのテストに使⽤できる iOS、Android、 および Fire OS の実機は増え続けています。デバイス群は、市場の データとお客様からのフィードバックをもとに、今後も引き続き更 新していく予定です。⼀覧は次のリストをご覧ください。 • http://awsdevicefarm.info/