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
Compose で手に入れた UI の Unit test
Search
mkeeda
March 10, 2023
Programming
3
2k
Compose で手に入れた UI の Unit test
Android Test Night #8 で話したスライド
https://testnight.connpass.com/event/274733/
mkeeda
March 10, 2023
Tweet
Share
More Decks by mkeeda
See All by mkeeda
DataStoreをテストする
mkeeda
0
360
時計仕掛けのCompose
mkeeda
1
380
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
670
手動DIの教訓
mkeeda
0
200
WebViewと向き合う
mkeeda
2
1.3k
お気に入りのAndroid Studio小技集
mkeeda
0
340
Scalable UI testing solutions かんたんまとめ
mkeeda
0
1.1k
5分で分かるビルドロジック共通化の今
mkeeda
1
1.5k
Jetpack Compose 完全に理解した
mkeeda
1
3.7k
Other Decks in Programming
See All in Programming
Webの外へ飛び出せ NativePHPが切り拓くPHPの未来
takuyakatsusa
2
190
社内での開発コミュニティ活動とモジュラーモノリス標準化事例のご紹介/xPalette and Introduction of Modular monolith standardization
m4maruyama
1
130
deno-redisの紹介とJSRパッケージの運用について (toranoana.deno #21)
uki00a
0
130
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
380
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
210
XP, Testing and ninja testing
m_seki
2
130
PHP 8.4の新機能「プロパティフック」から学ぶオブジェクト指向設計とリスコフの置換原則
kentaroutakeda
1
310
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
390
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
1
360
KotlinConf 2025 現地で感じたServer-Side Kotlin
n_takehata
1
220
ドメインモデリングにおける抽象の役割、tagless-finalによるDSL構築、そして型安全な最適化
knih
11
2k
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
1
160
Featured
See All Featured
Done Done
chrislema
184
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Navigating Team Friction
lara
187
15k
Statistics for Hackers
jakevdp
799
220k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
The Language of Interfaces
destraynor
158
25k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
130
19k
Writing Fast Ruby
sferik
628
61k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Documentation Writing (for coders)
carmenintech
71
4.9k
Designing for Performance
lara
609
69k
Transcript
Compose UI Unit test 2 02 3 / 03 /
10 Android Test Night # 8 mkeeda
About me • mkeeda (Ҫా Ұฏ) • Twitter: @mr_mkeeda •
Github: @mkeeda • Android Engineer at Cybozu, Inc 2
Android UI 3
Domain Layer UI Layer Data Layer 4 UI elements State
holders UseCases Repositories DataSources ViewModelTest UseCaseTest RepositoryTest DatabaseTest, NetworkTest
End-to-end test 5 Domain Layer UI Layer Data Layer UI
elements State holders UseCases Repositories DataSources Espresso performAction() & assert() 😍 🤮 🤮
6 Domain Layer UI Layer Data Layer UI elements State
holders UseCases Repositories DataSources Unit test : UI ViewModel or Fake 🤮 😍 😍
UI Unit test UI disable 7 Domain Layer UI
Layer Data Layer UI elements State holders UseCases Repositories DataSources
Jetpack Compose UI f(UI state) = UI 8 @Preview @Composable
fun IntTextFieldPreview() { Surface { IntTextField( value = 0, onValueChange = {} ) } }
Compose UI 9 @Test fun `Ҏ֎ೖྗͰ͖ͳ͍`() = runComposeUiTest { var
userInputText: Int? by mutableStateOf(0) setContent { IntTextField( value = userInputText, onValueChange = { userInputText = it } ) } val notInt = "sample" onNode(hasSetTextAction()).performTextInput(notInt) onNodeWithText(notInt).assertDoesNotExist() assertThat(userInputText).isEqualTo(0) } ComposeTestRule UI
10 https://www.youtube.com/watch?v=JyUJZvJ-OV 8
UI Unit test UI UI Screenshot test 11 https://www.droidcon.com/ 20
22 / 08 / 01 /modern-testing-on-android/
Unit test 12
Instrumented test Android CI Android Robolectric Instrumented test Local test
13
My app Android framework Instrumented test (AndroidView) 14 android.view.View MyView
Android Runtime Espresso performAction() & assert()
Android class ⾒ Local test with Robolectric (AndroidView) My app
Robolectric ShadowView MyView Local JVM Espresso performAction() & assert()
Instrumented test (Compose) 16 Compose test library performAction() & assert()
My app Android framework android.graphic.Canvas MyComposable Android Runtime Compose Runtime
Semantic assert Shadow Local test with Robolectric (Compose) 17 Compose
test library performAction() & assert() My app Robolectric ShadowCanvas MyComposable Local JVM Compose Runtime
UI UI Compose UI Compose Robolectric Compose UI 18