and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 自己紹介 伊藤 智行 @tmyk110 株式会社アンドパッド SETアプリチーム所属 モバイルアプリ開発での品質向上、生産性向上に 取り組んでいます 最近はおうちコーヒーにハマっています☕ Confidential
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 会社紹介 株式会社アンドパッド 施工管理アプリ「ANDPAD」を提 供しています ミッション: 幸せを築く人を、幸せに。 絶賛採用強化中! Confidential
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 イベント紹介 アンドパッドの雰囲気やエンジニアがわかる内容になっています ぜひご視聴ください! Confidential
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 対象プロダクト Confidential 会社内や建築案件に関わるメンバー とメッセージのやりとりができるチャッ トアプリ REST API + RDB から Firestore にシ ステム移行中
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 SET立ち上げ時の会話 Confidential 品質あげていくにはどうしたらいい ですかねー? テストカバレッジが指標として良さ そうですね。30%くらい。 いいですね、それやりましょう。 じゃあよろしくね。 はい。。。! CDO CDO 顧問
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 30%に向けて Confidential レイヤー コード行数 割合 View・ViewController 6.3k 60% ViewModel 1.4k 13% Model・Logic 1.2k 11% Network 1.6k 15% カバレッジ30%の目標を達成したい。View以外ならテスト書けそう?
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Network部分のモック化 ・REST APIクライアント → MockerでURLProtocolをモック化 Confidential ・Firestoreクライアント → モック化する仕組みは用意されていない? 🤔? 😄
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Firestoreエミュレータについて Confidential https://firebase.google.com/docs/emulator-suite?hl=ja ローカルマシンにFirestore環境を構築できる。 Firebaseエミュレータに含まれている
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 セットアップ Confidential 1. Firebase CLIのインストールと初期化 2. Firebase エミュレータの設定 3. Firebase エミュレータの起動 4. ローカルホストにアクセス
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 ユニットテストで使うために Confidential
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 プロダクトコード例 Confidential チャットルームの一覧を取得するメソッドを例にします
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 FirebaseAppのセットアップと削除 Confidential テスト毎のsetup()とteardown()でFirebaseAppの制御をします
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 テストデータの書き込み Confidential 汎用的にテストデータを書き込むメソッドを用意します
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 テストコード例 Confidential テストデータ書き込み → メソッドの実行 → 実行結果の確認
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 (FYI) 事前にimportする方法 Confidential CLIでエミュレータ起動時に「--import」オプションで初期データの書き込 みが可能 (事前にexportしておいたもの) (使わなかった理由) ・テストデータとテスト内容をセットで管理したかった ・バイナリデータなのでテキストエディタで編集できない ・テスト毎にprojectを作っているので、ちょっと難しい
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 Bitriseで実行した結果 Confidential BitriseのCI環境にはfirebase CLIがプリインストールされている → 追加の設定なくFirestoreエミュレータのテストが実行できました!
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://goo.gl/ctyzm8. Terminating app due to uncaught exception 'com.firebase.installations', reason: 'The default FirebaseApp instance must be configured before the defaultFirebaseApp instance can be initialized. 挙動が不安定 ・エミュレータから応答がなくT.Oしてしまうことがある ・テスト中に例外が発生してしまうことがある Confidential
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 時刻が合わない Confidential ・CI環境にてテストデータとしてエミュレータに書き込んだ時刻 を、再度読み出した時の時刻がずれている ・エミュレータ側のタイムゾーン等の問題か?
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 エラーのテストができない Confidential ・通信エラーなどを再現する機能がない? ・エラーハンドリングの処理をテストすることができず
and was prepared by ANDPAD Inc. for the use of our client. It is not to be relied on by and 3rd party. Proprietary & Confidential 無断転載・無断複製の禁止 さいごに ・Firestoreエミュレータを使ったユニットテストは まだ安定運用できておらず ・ブログ記事などの情報もまだまだ少ないです ・同じ悩みをお持ちの方ぜひ情報交換していきましょう Confidential