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.9k
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
DataStoreをテストする
mkeeda
0
330
時計仕掛けのCompose
mkeeda
1
370
What's new in Firebase for building gen AI features気になったところ
mkeeda
0
630
手動DIの教訓
mkeeda
0
200
WebViewと向き合う
mkeeda
2
1.3k
お気に入りのAndroid Studio小技集
mkeeda
0
340
Scalable UI testing solutions かんたんまとめ
mkeeda
0
1.1k
5分で分かるビルドロジック共通化の今
mkeeda
1
1.5k
Jetpack Compose 完全に理解した
mkeeda
1
3.7k
Other Decks in Programming
See All in Programming
RubyKaigi Hack Space in Tokyo & 函館最速 "予習" 会 / RubyKaigi Hack Space in Tokyo & The Fastest Briefing of RubyKaigi 2026 in Hakodate
moznion
1
110
医療系ソフトウェアのAI駆動開発
koukimiura
1
170
CRUD から CQRS へ ~ 分離が可能にする柔軟性
tkawae
0
210
なぜHono×GraphQLを選んだのか?
junichi_fukushima
0
880
衛星の軌道をWeb地図上に表示する
sankichi92
0
220
CQRS/ESのクラスとシステムフロー ~ RailsでフルスクラッチでCQRSESを組んで みたことから得た学び~
suzukimar
0
180
DevDay2025-OracleDatabase-kernel-addressing-history
oracle4engineer
PRO
6
1.5k
AI時代のリアーキテクチャ戦略 / Re-architecture Strategy in the AI Era
dachi023
0
180
がんばりすぎないコーディングルール運用術
tsukakei
1
110
try-catchを使わないエラーハンドリング!? PHPでResult型の考え方を取り入れてみよう
kajitack
3
140
Investigating Multithreaded PostgreSQL
macdice
0
130
CursorとDevinが仲間!?AI駆動で新規プロダクト開発に挑んだ3ヶ月を振り返る / A Story of New Product Development with Cursor and Devin
rkaga
5
1.8k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
25
2.8k
Automating Front-end Workflow
addyosmani
1370
200k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
52
2.8k
Designing for humans not robots
tammielis
253
25k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Become a Pro
speakerdeck
PRO
28
5.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
14
880
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
5
640
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
105
19k
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