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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
170
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
5.5k
Android StudioのAIコーディングツール、 ぶっちゃけどうなん???
mkeeda
0
550
DataStoreをテストする
mkeeda
0
580
時計仕掛けのCompose
mkeeda
1
550
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
940
手動DIの教訓
mkeeda
0
300
WebViewと向き合う
mkeeda
2
1.6k
お気に入りのAndroid Studio小技集
mkeeda
0
400
Other Decks in Programming
See All in Programming
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.5k
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
810
AIとRubyの静的型付け
ukin0k0
0
530
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.5k
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
460
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
310
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
340
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
1
700
Moments When Things Go Wrong
aurimas
3
140
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
600
Scaling GitHub
holman
464
140k
Designing Experiences People Love
moore
143
24k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
320
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
The Language of Interfaces
destraynor
162
27k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
The Limits of Empathy - UXLibs8
cassininazir
1
350
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
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