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
2
1.1k
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
手動DIの教訓
mkeeda
0
87
WebViewと向き合う
mkeeda
1
680
お気に入りのAndroid Studio小技集
mkeeda
0
230
Scalable UI testing solutions かんたんまとめ
mkeeda
0
560
5分で分かるビルドロジック共通化の今
mkeeda
1
550
Jetpack Compose 完全に理解した
mkeeda
1
2.6k
5分でわかるCompose Modifiers deep dive
mkeeda
1
730
みんなで準備するスポンサー
mkeeda
0
170
What's new in Android development tools まとめ
mkeeda
0
1.3k
Other Decks in Programming
See All in Programming
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
3
770
Ruby GitHub Packages
bkuhlmann
0
620
Rails と人魚の話/rails-and-mermaid
sanfrecce_osaka
0
100
Build with AI 2024 Seoul - 제로부터 시작하는 Flutter with Gemini 생활 - 박제창
itsmedreamwalker
0
200
HUIT新歓2024「競技プログラミング、やってみませんか?」
slephy2784
1
250
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
300
SpringBoot+MyBatisで例外が出たときどこを見るか
syukai
0
110
プールにゆこう
irof
2
120
今、知っておきたい! 生成AIエージェントの世界
elith
3
340
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
39
18k
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
450
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
We Have a Design System, Now What?
morganepeng
42
6.7k
Web Components: a chance to create the future
zenorocha
305
41k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
Faster Mobile Websites
deanohume
297
30k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
GraphQLとの向き合い方2022年版
quramy
31
12k
Why Our Code Smells
bkeepers
PRO
331
56k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
The Invisible Customer
myddelton
114
12k
Git: the NoSQL Database
bkeepers
PRO
422
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