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
1.4k
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
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
260
手動DIの教訓
mkeeda
0
110
WebViewと向き合う
mkeeda
2
880
お気に入りのAndroid Studio小技集
mkeeda
0
260
Scalable UI testing solutions かんたんまとめ
mkeeda
0
760
5分で分かるビルドロジック共通化の今
mkeeda
1
760
Jetpack Compose 完全に理解した
mkeeda
1
2.9k
5分でわかるCompose Modifiers deep dive
mkeeda
1
820
みんなで準備するスポンサー
mkeeda
0
200
Other Decks in Programming
See All in Programming
Product Management LT会_クアンド新家
shinshin
0
210
Terraformテスト入門
msato
0
520
企業向け生成AIアプリの 開発から得られた知見
takaakikakei
0
310
Xcode 16のPreviewModifierと@Previewableを活用した効率的なプレビュー方法の考察
ojun9
2
160
英語
s_shimotori
1
220
Async Await: Mastering Python's Time-Bending Tricks - EuroPython2024
yanbo
1
290
生成AIをkintoneに連携してみた
hideg
0
230
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.9k
20240706_CDKConf
takuyay0ne
0
1.2k
初心者がおさえておきたいAWS CDKのベストプラクティス 2024
konokenj
15
7.3k
Temporalを取り巻く仕様を整理する
sajikix
0
110
Folding Cheat Sheet #7
philipschwarz
PRO
0
150
Featured
See All Featured
Gamification - CAS2011
davidbonilla
78
4.9k
5 minutes of I Can Smell Your CMS
philhawksworth
200
19k
Visualization
eitanlees
139
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
78
15k
The Cult of Friendly URLs
andyhume
75
5.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
399
65k
Adopting Sorbet at Scale
ufuk
71
8.8k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
90
47k
What the flash - Photography Introduction
edds
65
11k
Designing on Purpose - Digital PM Summit 2013
jponch
113
6.6k
Mobile First: as difficult as doing things right
swwweet
219
8.8k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
2.9k
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