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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mkeeda
March 10, 2023
Programming
2.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
Google I/O 2026 個人的に気になりトピック
mkeeda
0
33
アジャイル & スクラム入門
mkeeda
0
210
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
5.6k
Android StudioのAIコーディングツール、 ぶっちゃけどうなん???
mkeeda
0
660
DataStoreをテストする
mkeeda
0
610
時計仕掛けのCompose
mkeeda
1
580
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
1k
手動DIの教訓
mkeeda
0
320
WebViewと向き合う
mkeeda
2
1.7k
Other Decks in Programming
See All in Programming
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
190
業務時間外もAIに働いてもらう話
colorful12
2
9.1k
AI Readyの正体はデータマネジメントだ メダリオン2.0の最前線
freee
PRO
0
450
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
230
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
240
高専キャリア LT 発表内容
crysta1221
6
5k
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
270
初めての模倣学習とVLA
natsutan
0
330
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
580
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
120
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
530
ソフトウェアラスタライザ
fadis
1
740
Featured
See All Featured
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
310
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Designing for Timeless Needs
cassininazir
1
460
WCS-LA-2024
lcolladotor
0
810
WENDY [Excerpt]
tessaabrams
12
39k
So, you think you're a good person
axbom
PRO
2
2.1k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
580
The Invisible Side of Design
smashingmag
301
52k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
How to Think Like a Performance Engineer
csswizardry
28
2.8k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
310
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
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