Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RxJavaのアプリをEspressoでテストする簡単な方法

Kenta Kase
January 26, 2018

 RxJavaのアプリをEspressoでテストする簡単な方法

DroidKaigi Preludeでの発表スライドです。
https://connpass.com/event/73367/
RxJavaアプリをEspressoでテストするときに問題となる非同期処理を解決してくれるRxIdlerを紹介します

Kenta Kase

January 26, 2018
Tweet

More Decks by Kenta Kase

Other Decks in Programming

Transcript

  1. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. DroidKaigi Prelude LT


    2018/01/026(Fri) Ճ੉݈ଠ@DeNA RxJavaͷΞϓϦΛ
 EspressoͰςετ͢Δ؆୯ͳํ๏ 1
  2. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ࣗݾ঺հ w Ճ੉݈ଠʢ!,FTJOʣ

    ⁃ ॴଐ • %F/"48&5άϧʔϓςετج൫νʔϜ ⁃ ۀ຿ • ϞόΠϧςετͷௐࠪɺ஌ݟͷڞ༗ • ଞࣄۀ෦ͷۀ຿ޮ཰Խαϙʔτ ⁃ झຯͰ3FBDU/BUJWFΛ࠷ۙ৮Γ࢝Ί·ͨ͠ 2
  3. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. &TQSFTTPͱ͸ w (PPHMF͕ఏڙ͍ͯ͠Δ"OESPJEͷ6*ςετϑϨʔϜϫʔΫ

    w +7.Ͱ͸ͳͯ͘"OESPJE্ͰςετΛ࣮ߦͤ͞Δ w 6*ཁૉͷૢ࡞ɺςετ͕Ͱ͖Δ 3
  4. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. σϞ 4 w

    %SPJE,BJHJͷΞϓϦ Ͱ6*ςετ w $POUSJCVUPST͕ଘࡏ͢Δ͔ w ݕࡧ͕ػೳ͢Δ͔ w .Z4FTTJPOͷొ࿥ɾղআ͕ ਖ਼͘͠ಈ࡞͢Δ͔
  5. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. &TQSFTTPͱඇಉظॲཧ w ͋Δཁૉ͕දࣔ͞Ε͍ͯΔ͜ͱΛςετ͍ͨ͠έʔε

    w ඇಉظॲཧͰཁૉΛද͍ࣔͤͯ͞Δ৔߹͸଴ͭඞཁ͕͋Δ w &TQSFTTP͸.FTTBHF2VFVFͱ"TZOD5BTLΛࣗಈతʹ଴ͬͯ ͘ΕΔ w *EMJOH3FTPVSDFTͱ͍͏ηϚϑΥͷΑ͏ͳ࢓૊ΈͰ΋ίϯτ ϩʔϧՄೳ 5
  6. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. 3Y+BWBʹରͯ͠ແྗ 7 w

    3Y+BWB͸ผͷ࢓૊ΈͰඇಉ ظॲཧΛ͍ͯ͠ΔͨΊ w &TQSFTTP͕3Y+BWBͷඇಉ ظॲཧΛ଴ͭ͜ͱ͕Ͱ͖ͳ ͍ͷͰ6*ςετ͕·ͱ΋ʹ ಈ࡞͠ͳ͍
  7. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. 3Y*EMFS w IUUQTHJUIVCDPNTRVBSF3Y*EMFS

    w ೥݄ʹϦϦʔε w গ͠ͷίʔυΛॻ͚ͩ͘Ͱ&TQSFTTPΛ3Y+BWBʹରԠͤ͞Δ͜ ͱ͕Ͱ͖Δ w ࠓ೔͸͜Ε͚֮ͩ͑ͯ΋Β͑Ε͹0,Ͱ͢ 9
  8. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. αϯϓϧίʔυ w "OESPJE+6OJU3VOOFSΛܧঝͨ͠ΫϥεΛ࡞Δ

    ⁃ ࠩ͠ସ͑Δεέδϡʔϥʔ͸ΞϓϦͷ࣮૷࣍ୈ • 4DIFEVMFSTJPͳΒ3Y+BWB1MVHJOTTFU*OJU*P4DIFEVMFS)BOEMFSΛ࢖͏ w CVJMEHSBEMFͷUFTU*OTUSVNFOUBUJPO3VOOFSΛ࡞੒ͨ͠Ϋϥε ʹஔ͖׵͑Δ w ޙ͸ී௨ʹ&TQSFTTPͷςετΛॻ͚ͩ͘ 10 public class RxIdlerTestRunner extends AndroidJUnitRunner { @Override public void onStart() { RxJavaPlugins.setInitIoSchedulerHandler(Rx2Idler.create("IoSceduler")); super.onStart(); } } testInstrumentationRunner "io.github.droidkaigi.confsched2017.RxIdlerTestRunner"
  9. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. 3Y*EMFSͷ࢓૊Έ w 3Y*EMFS͕*EMJOH3FTPVSDFTͷΠϯλʔϑΣʔεΛ࣮૷ͨ͠

    4DIFEVMFSΛ༻ҙ͠ɺ3Y+BWBͷQMVHJOͰࠩ͠ସ͍͑ͯΔ ⁃ ඇಉظॲཧTUBSUˠ*EMJOH3FTPVSDFTΛΠϯΫϦϝϯτ ⁃ ඇಉظॲཧFOEˠ*EMJOH3FTPVSDFTΛσΫϦϝϯτ w ݩʑͦͷΑ͏ͳ࣮૷ํ๏͸঺հ͞Ε͍ͯͨɻ3Y*EMFS͸ͦΕΛ ѻ͍΍͍ͯ͘͢͠Δ ⁃ 3Y+BWBͷඇಉظॲཧʹෛ͚ͳ͍&TQSFTTPςετίʔυΛॻ͘ • IUUQTTQFBLFSEFDLDPNTVNJPMFUTXSJUFFTQSFTTPUFTUTTZODISPOJ[JOHXJUI SYKBWBTBTZODISPOPVTQSPDFTTJOH TMJEF ⁃ 3Y"OESPJEJTTVF • IUUQTHJUIVCDPN3FBDUJWF93Y"OESPJEJTTVFTJTTVFDPNNFOU 11
  10. Copyright (C) DeNA Co.,Ltd. All Rights Reserved. ·ͱΊ w 3Y+BWBͷΞϓϦͷ6*ςετΛॻ͘ͷͳΒ͹3Y*EMFS͓͢͢Ί

    w 3Y+BWBͱ&TQSFTTPͷਂ͍࢓૊ΈΛཧղ͠ͳͯ͘΋
 গͳ͍ίʔυͰ࣮ݱͰ͖Δ w 3Y+BWBͱ&TQSFTTPͷৄ͍͠࿩͸%SPJELBJHJͰ
 ൃද͞ΕΔ͸ͣʂʂ 12