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
2.2k
3
Share
Compose で手に入れた UI の Unit test
Android Test Night #8 で話したスライド
https://testnight.connpass.com/event/274733/
mkeeda
March 10, 2023
More Decks by mkeeda
See All by mkeeda
アジャイル & スクラム入門
mkeeda
0
150
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
5.5k
Android StudioのAIコーディングツール、 ぶっちゃけどうなん???
mkeeda
0
510
DataStoreをテストする
mkeeda
0
570
時計仕掛けのCompose
mkeeda
1
530
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
910
手動DIの教訓
mkeeda
0
280
WebViewと向き合う
mkeeda
2
1.6k
お気に入りのAndroid Studio小技集
mkeeda
0
400
Other Decks in Programming
See All in Programming
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.4k
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
950
PHP で mp3 プレイヤーを実装しよう
m3m0r7
PRO
0
300
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
170
書き換えて学ぶTemporal #fukts
pirosikick
2
320
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
110
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
270
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
290
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.5k
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
360
[RubyKaigi 2026] Require Hooks
palkan
1
280
🦞OpenClaw works with AWS
licux
1
320
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
37
7.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
sira's awesome portfolio website redesign presentation
elsirapls
0
230
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
Bash Introduction
62gerente
615
210k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
210
Code Review Best Practice
trishagee
74
20k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.8k
Context Engineering - Making Every Token Count
addyosmani
9
860
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
330
For a Future-Friendly Web
brad_frost
183
10k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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