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
Espresso Idling Resource
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Takuji Nishibayashi
August 29, 2017
Technology
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Espresso Idling Resource
Takuji Nishibayashi
August 29, 2017
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
compose-hot-reload を試そうとした話
takuji31
0
170
CameraX使ってみた
takuji31
0
320
kotlinx.datetime 使ってみた
takuji31
0
1.1k
HiltのCustom Componentについて
takuji31
0
390
java.timeをAndroidで使う
takuji31
0
210
KSPを使ってコード生成
takuji31
0
490
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
3.2k
kotlinx.serialization
takuji31
0
710
kanmoba-returns-02.pdf
takuji31
0
300
Other Decks in Technology
See All in Technology
AI-DLCって実際どう? 〜聞きたいこと全部聞いてみる〜
news_it_enj
0
220
Genie Code ワークショップ 基礎編 / Genie-Code-Workshop-fundamental
databricksjapan
PRO
0
340
【試作】IoT x AIエージェント
happysamurai294
0
120
スクラムで身についていた動き方を、XPで捉え直してみた
codmoninc
1
180
Beyond the Hype: Practical AI for Your Oracle Database with MCP
thatjeffsmith
1
230
設計の世代交代を乗り越える、14年続くAndroidアプリの開発戦略
sansantech
PRO
1
110
いかに伝えるか 〜新卒エンジニアの教育のための、ライトノベル活用の一例
ikedon
1
190
本番に近いテストをもっと手軽に - Postmanで広がるAPIテストの世界 / Expanding the World of API Testing with Postman
yokawasa
1
240
AIとペアプロを始める。人とのペアプロをやめる。ペアプロの良さを改めて知る。もっと好きになった。 / Rediscovering Pair Programming
honyanya
1
190
プロダクトエンジニアに必要な「いい感じ」に作る能力 〜たくさん作れる時代に、どこまで作るかの決め方〜
jnishime_dresscode
2
1.2k
どんな手を使っても絶対間に合わせるスケジューラ
asari194617
0
1.5k
全社に広がるMCPサーバーを、 どう安全に管理するか MCPass開発の舞台裏
mtpooh
3
280
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
The browser strikes back
jonoalderson
0
1.6k
BBQ
matthewcrist
89
10k
Navigating Weather and Climate Data
rabernat
0
510
KATA
mclloyd
PRO
35
15k
Test your architecture with Archunit
thirion
2
2.4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Designing for humans not robots
tammielis
254
26k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
230
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
410
Transcript
Espresso Idling Resource ☕ @takuji31
@takuji31 (Takuji Nishibayashi) Applica7on Engineer at Hatena
Loves • ! (AVG 175) • " # • h,p:/
/photo.takuji31.jp • $ • h,p:/ /nazuna.takuji31.jp • Android • Kotlin
AGENDA • UIςετΛॻ࣌͘ͷΈ • ղܾํ๏ • Espresso Idling Resource •
ϋϚΓͲ͜Ζ
UIςετΛॻ࣌͘ͷΈ
ඇಉظͷςετ
ςετ͕ՄೳʹͳΔ·Ͱͭ
ࡶͳղܾํ๏
Thread.sleep(1000)
ωοτϫʔΫ͕͍
ͨ·ʹίέΔ !
Jenkins͕ॏ͍
ͨ·ʹίέΔ !
ͪΐͬͱݡ͍ํ๏
खͰؤுΔ
RxJava
Թ͔Έͷ͋Δख࣮
ෳίϯϙʔωϯτΛͭͷ͕େม Ac#vity + ViewModelͱ͔
ຊ࣭తͰͳ͍ͱ͜Ζʹίετ͕͔͔ Γ͗͢Δ
ઈରΓͨ͘ͳ͍ !
Espresso Idling Resource
Espresso plugin?
ΞΠυϦϯάͷΈΛఏڙ
IdlingResource
Ϧιʔε
IdlingRegistry
ΞΠυϦϯάΛࢹ͢ΔϨδετϦ ʔ
͍ํ
build.gradle compile 'com.android.support.test.espresso:espresso-idling-resource:3.0.0'
IdlingResource
SimpleIdlingResource class SimpleIdlingResource(private val name: String) : IdlingResource { private
var callback: IdlingResource.ResourceCallback? = null var isIdle: Boolean = false set(value) { field = value if (value) { callback?.run { onTransitionToIdle() } } } override fun getName(): String = this.name override fun isIdleNow(): Boolean = isIdle override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) { this.callback = callback } }
͏
ΞϓϦ
ViewModel class ViewModel { var artists: List<Artist> = emptyList() var
loadingDisposable: Disposable? = null @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) val loadingIdlingResource : SimpleIdlingResource = SimpleIdlingResource("IdlingResourceViewModelLoading") }
ViewModel class ViewModel { fun onCreate() { // fake API
request fakeReload() } private fun fakeReload() { loadingDisposable = Single .timer(3, TimeUnit.SECONDS) .doOnSubscribe { loadingIdlingResource.isIdle = false } .doFinally { loadingIdlingResource.isIdle = true } .subscribe { _, _ -> artists = Artist.list } } }
ςετ
test class IdlingResourceActivityTest { @JvmField @Rule val rule : IntentsTestRule<IdlingResourceActivity>
= IntentsTestRule(IdlingResourceActivity::class.java, true, true) var initializeIdlingResource : IdlingResource? = null }
test class IdlingResourceActivityTest { @Before fun setUp() { initializeIdlingResource =
rule.activity.viewModel.loadingIdlingResource IdlingRegistry.getInstance().register(initializeIdlingResource) } @After fun tearDown() { initializeIdlingResource?.run { IdlingRegistry.getInstance().unregister(this) initializeIdlingResource = null } } }
test class IdlingResourceActivityTest { @Test fun testReload() { // remove
3 items repeat(3) { openActionBarOverflowOrOptionsMenu(rule.activity) onView(withText("Remove first")).perform(click()) } onView(withId(R.id.swipeRefreshLayout)).perform(swipeDown()) onView(withId(R.id.recyclerView)).check { view, _ -> val recyclerView = view as RecyclerView assertEquals(recyclerView.childCount, Artist.list.size) assertEquals(recyclerView.adapter.itemCount, Artist.list.size) } } }
EspressoͷػೳΛΘͳ͍͚Ͳͪ ͍ͨ
ex) GAͷΠϕϯτૹ৴Λςετ
Espresso.onIdle()
༻ҙ͞Ε͍ͯΔIdlingResource
CountingIdlingResource
ηϚϑΥͬΆ͍ͭ
increment()/decrement()
IdlingScheduledThreadPoolExecutor / IdlingThreadPoolExecutor
ThreadPoolExecutor
UriIdlingResource
UriΛΩʔʹͰ͖ΔIdlingResource
ϋϚΓͲ͜Ζ
Test with Proguard
None
!
Proguard rule -keep class android.support.test.espresso.** { public *; }
takuji31/KanmobaAndroid
Enjoy Espresso life !