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.5k
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
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
330
手動DIの教訓
mkeeda
0
130
WebViewと向き合う
mkeeda
2
970
お気に入りのAndroid Studio小技集
mkeeda
0
270
Scalable UI testing solutions かんたんまとめ
mkeeda
0
820
5分で分かるビルドロジック共通化の今
mkeeda
1
880
Jetpack Compose 完全に理解した
mkeeda
1
3.1k
5分でわかるCompose Modifiers deep dive
mkeeda
1
860
みんなで準備するスポンサー
mkeeda
0
210
Other Decks in Programming
See All in Programming
Wallet API, Verifier APIで実現するIDカード on iPhoneの世界
shitamori1272
1
340
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
130
Scala アプリケーションのビルドを改善してデプロイ時間を 1/4 にした話 | How I improved the build of my Scala application and reduced deployment time by 4x
nomadblacky
1
110
dRuby 入門者によるあなたの身近にあるdRuby 入門
makicamel
4
340
RAGの回答精度評価用のQAデータセットを生成AIに作らせた話
kurahara
0
220
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
310
ウォンテッドリーにおけるモバイルアプリ開発 / iOSDC Japan 2024 Sponsor Session
kubode
0
230
デザインシステムとコンポーネント指向によるフロントエンド開発プロセスの革新 / Innovation in Frontend Development Processes through Design Systems and Component-Oriented Architecture
nrslib
7
5.1k
全力の跳躍を捉える計測アプリを作る
ogijun2018
0
1.1k
Kotlin 2.0 and Beyond
antonarhipov
2
140
null or undefined
susisu
22
5.7k
LangChainの現在とv0.3にむけて
os1ma
3
720
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
363
22k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
354
29k
Fireside Chat
paigeccino
31
2.9k
Statistics for Hackers
jakevdp
793
220k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
58k
In The Pink: A Labor of Love
frogandcode
139
22k
The Invisible Side of Design
smashingmag
295
50k
Build The Right Thing And Hit Your Dates
maggiecrowley
30
2.2k
Gamification - CAS2011
davidbonilla
79
4.9k
The Cost Of JavaScript in 2023
addyosmani
39
5.2k
Web development in the modern age
philhawksworth
204
10k
GraphQLの誤解/rethinking-graphql
sonatard
65
9.7k
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