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.9k
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
290
時計仕掛けのCompose
mkeeda
1
360
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
580
手動DIの教訓
mkeeda
0
200
WebViewと向き合う
mkeeda
2
1.3k
お気に入りのAndroid Studio小技集
mkeeda
0
330
Scalable UI testing solutions かんたんまとめ
mkeeda
0
1.1k
5分で分かるビルドロジック共通化の今
mkeeda
1
1.5k
Jetpack Compose 完全に理解した
mkeeda
1
3.6k
Other Decks in Programming
See All in Programming
VitestのIn-Source Testingが便利
taro28
6
2k
AWSで雰囲気でつくる! VRChatの写真変換ピタゴラスイッチ
anatofuz
0
160
Thank you <💅>, What's the Next?
ahoxa
1
390
生成AIを使ったQAアプリケーションの作成 - ハンズオン補足資料
oracle4engineer
PRO
3
240
スモールスタートで始めるためのLambda×モノリス(Lambdalith)
akihisaikeda
2
280
海外のアプリで見かけたかっこいいTransitionを真似てみる
shogotakasaki
1
170
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
0
110
Enterprise Web App. Development (1): Build Tool Training Ver. 5
knakagawa
1
120
設計の本質:コード、システム、そして組織へ / The Essence of Design: To Code, Systems, and Organizations
nrslib
4
540
Cursor/Devin全社導入の理想と現実
saitoryc
5
1k
Sharing features among Android applications: experience feedback
jbvincey
0
110
Agentic Applications with Symfony
el_stoffel
2
310
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
37
1.7k
Thoughts on Productivity
jonyablonski
69
4.6k
Designing Experiences People Love
moore
141
24k
Reflections from 52 weeks, 52 projects
jeffersonlam
349
20k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Code Reviewing Like a Champion
maltzj
522
40k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
30k
Unsuck your backbone
ammeep
670
57k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
178
53k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.6k
Building Adaptive Systems
keathley
41
2.5k
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