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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
mkeeda
March 10, 2023
Programming
3
2.2k
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
そのAPI、誰のため? Androidライブラリ設計における利用者目線の実践テクニック
mkeeda
2
5.4k
Android StudioのAIコーディングツール、 ぶっちゃけどうなん???
mkeeda
0
450
DataStoreをテストする
mkeeda
0
540
時計仕掛けのCompose
mkeeda
1
490
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
870
手動DIの教訓
mkeeda
0
260
WebViewと向き合う
mkeeda
2
1.6k
お気に入りのAndroid Studio小技集
mkeeda
0
390
Scalable UI testing solutions かんたんまとめ
mkeeda
0
1.3k
Other Decks in Programming
See All in Programming
How to stabilize UI tests using XCTest
akkeylab
0
120
Codex の「自走力」を高める
yorifuji
0
1.2k
Claude Code Skill入門
mayahoney
0
330
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
730
Docコメントで始める簡単ガードレール
keisukeikeda
1
110
20260313 - Grafana & Friends Taipei #1 - Kubernetes v1.36 的開發雜記:那些困在 Alpha 加護病房太久的 Metrics
tico88612
0
180
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
440
文字コードの話
qnighy
44
17k
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
140
SourceGeneratorのマーカー属性問題について
htkym
0
190
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
150
ロボットのための工場に灯りは要らない
watany
10
2.8k
Featured
See All Featured
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
300
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
WCS-LA-2024
lcolladotor
0
480
Odyssey Design
rkendrick25
PRO
2
540
HDC tutorial
michielstock
1
540
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
470
Building an army of robots
kneath
306
46k
Code Review Best Practice
trishagee
74
20k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.2k
Writing Fast Ruby
sferik
630
63k
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