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
UI State設計とテスト方針
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
rmakiyama
December 20, 2024
Technology
4
1.2k
UI State設計とテスト方針
Ebisu.mobile #8 大忘年会 STORES kubell Kyash asken
https://hey.connpass.com/event/335971/
rmakiyama
December 20, 2024
Tweet
Share
More Decks by rmakiyama
See All by rmakiyama
KMPプロジェクトでマニュアルDIを使う選択
rmakiyama
0
480
Jetpack Composeとデザインシステム
rmakiyama
0
1.2k
TextField theme in Compose
rmakiyama
0
320
Androidエンジニアが1人という不安と向き合う
rmakiyama
6
7k
Jetpack Compose Canvas入門
rmakiyama
0
1.5k
HiltはDIをどうやってやっているのか
rmakiyama
1
310
Radiotalk Androidアプリにおけるモジュール分割の課題とこれから
rmakiyama
1
350
Androidでオーディオアプリを作るということ
rmakiyama
1
3.3k
getChangePayload in DiffUtil
rmakiyama
0
3.3k
Other Decks in Technology
See All in Technology
自動テストが巻き起こした開発プロセス・チームの変化 / Impact of Automated Testing on Development Cycles and Team Dynamics
codmoninc
1
1.1k
Ultra Ethernet (UEC) v1.0 仕様概説
markunet
3
200
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
4k
クラウド時代における一時権限取得
krrrr38
1
160
男(監査)はつらいよ - Policy as CodeからAIエージェントへ
ken5scal
5
730
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
15
95k
白金鉱業Meetup_Vol.22_Orbital Senseを支える衛星画像のマルチモーダルエンベディングと地理空間のあいまい検索技術
brainpadpr
2
200
Oracle Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
5
1.1k
Introduction to Bill One Development Engineer
sansan33
PRO
0
380
Security Diaries of an Open Source IAM
ahus1
0
200
社内でAWS BuilderCards体験会を立ち上げ、得られた気づき / 20260225 Masaki Okuda
shift_evolve
PRO
1
160
Kaggleの経験が実務にどう活きているか / kaggle_findy
sansan_randd
4
730
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
130
Side Projects
sachag
455
43k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
How to Talk to Developers About Accessibility
jct
2
140
Reality Check: Gamification 10 Years Later
codingconduct
0
2k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
79
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
150
Chasing Engaging Ingredients in Design
codingconduct
0
130
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
74
Transcript
©2024 Kyash Inc. ©2024 Kyash Inc. UI State設計とテスト方針 2024/12/20 rmakiyama(MAKIYAMA
Ryo) Ebisu.mobile #8 大忘年会 STORES kubell Kyash asken
©2024 Kyash Inc. 2 • Kyash Inc (2022/10 -) •
Android Engineer • Engineering Manager • @_rmakiyama • @rmakiyama MAKIYAMA Ryo 自己紹介
©2024 Kyash Inc. 3 Kyashについて お支払いも お金の管理も かんたんに Visaプリペイドカードとスマホで、いつでもどこでも、かんたんにお支払い。 アプリへのリアルタイムな履歴反映や自動カテゴリー分類で、お金の管理もかんたんに。
©2024 Kyash Inc. KyashとJetpack Compose • 2021年5月から導入開始 • Fragmentの上にComposeViewを載せる運用 •
新規実装する画面は基本的にJetpack Composeを利用 • 大小含め100画面以上を実装 Jetpack Composeがデファクトスタンダード 4 ※2024年5月現在
©2024 Kyash Inc. アジェンダ • KyashのKotlin Multiplatform構成 ◦ Reactor概説 ◦
UI Stateのサンプル • UI Stateの設計で考えていること • テスト方針 UI State設計とテスト方針 5
©2024 Kyash Inc. KyashのKMP構成概略 6 • ReactorKitを汲んだMVIライクな設計 ◦ State/Action/Event •
各OSでWrapper実装がある
©2024 Kyash Inc. KyashのKMP構成概略 / UI Layer 7
©2024 Kyash Inc. KyashのKMP構成概略 / UI Layer / Reactor 8
class InputAmountReactor( mainDispatcher: CoroutineDispatcher, ) : AbstractReactor<Reactor.LoadState<State>, Action, Mutation, Event>( mainDispatcher = mainDispatcher, initialState = Reactor.LoadState.Loading(), ) { override fun mutate(action: Action): Flow<Mutation> = flow {...} override fun reduce( state: Reactor.LoadState<State>, mutation: Mutation, ): Reactor.LoadState<State> = when (mutation) {...} data class State(...) : Reactor.State sealed class Action : Reactor.Action sealed class Mutation : AbstractReactor.Mutation sealed class Event : Reactor.Event }
©2024 Kyash Inc. ©2024 Kyash Inc. UI State設計⚒ 9 9
©2024 Kyash Inc. ©2024 Kyash Inc. 簡単なサンプル 10 10
©2024 Kyash Inc. Sample app 11
©2024 Kyash Inc. Sample app 12 • 金額を入力してOKをおしてSubmit • 金額を入力しないとOKが押せない
• 1000円以上でないとエラーとする
©2024 Kyash Inc. Sample app / UI State 13 data
class UiState( val amount: Long?, )
©2024 Kyash Inc. Sample app / UI State 14 data
class UiState( val amount: Long?, ) 🤔
©2024 Kyash Inc. Sample app / UI State 15 data
class UiState( val amount: Long?, ) : Reactor.State { val hasError: Boolean = amount &= null && amount &= 0L && amount < 1000L val buttonEnabled: Boolean = amount &= null && isError.not() }
©2024 Kyash Inc. Sample app / UI State 16 data
class UiState( val amount: Long?, ) : Reactor.State { val hasError: Boolean = amount &= null && amount &= 0L && amount < 1000L val buttonEnabled: Boolean = amount &= null && isError.not() } 関心の分離ができている! 仕様・振る舞いが見えてくる!
©2024 Kyash Inc. UI Stateの設計で考えていること UI Stateで仕様や振る舞いを表現する • 見た目(Element)と状態(State)で関心の分離をする ◦
Composable関数を簡単にレンダリングできるデータとして定義 • UIの理解容易性とテスタビリティを高める • ※ 網羅性を意識しすぎない 17 https://developer.android.com/topic/architecture/ui-layer
©2024 Kyash Inc. ©2024 Kyash Inc. テスト方針🧪 18 18
©2024 Kyash Inc. 2024年現在のKyashアプリのテスト方針 State Holder / UI Stateの ユニットテストを重点的にやる
• Reactorのユニットテストを最低限行う ◦ Actionに対するStateの期待値をテスト ◦ 状態遷移のテストはUI Stateに対するテスト • UIの振る舞いのテストの一部をカバー ◦ UI Stateの責務の工夫とセット 19
©2024 Kyash Inc. 2024年現在のKyashアプリのテスト方針の背景 問題をできるだけ早い段階で検出し 開発/アウトカムのフィードバックループを早めたい • KMPだとユニットテストのROIが高い ◦ バグの検出コストを最小限に抑える
• UIテストの責務を絞り効果を高める ◦ テストの関心を分離 ◦ UIロジックや外観のテストにフォーカス 20
©2024 Kyash Inc. Thank you!! • UIを見た目(Element)と状態(State)に分けてUI Stateを設計している ◦ UI
Stateで仕様や振る舞いを表現 • State Holder/UI Stateのテストで仕様や振る舞いのテストを一部カバー • みんなはどうやってる?このあと話しましょう!! まとめ 21
©2024 Kyash Inc. Last one… • モバイルエンジニアを募集中です! • 懇親会でも気軽に話しましょう! WE
ARE HIRING 22 エンジニアの求人一覧 Advent Calendar 2024
©2024 Kyash Inc.
©2024 Kyash Inc. Appendix 24 https://www.wantedly.com/companies/wantedly/post_articles/300999 https://developer.android.com/topic/architecture/ui-layer?hl=ja https://developer.android.com/topic/architecture/ui-layer/stateholders?hl=ja https://developer.android.com/develop/ui/compose/migrate/other-considerations?hl=ja#prio ritize-splitting-state
https://developer.android.com/training/testing/fundamentals/strategies?hl=ja https://developer.android.com/training/testing/fundamentals?hl=ja