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

Android CI: 2016 edition

0c8f21e528a49d714bd0e1629054bdf4?s=47 Yusuke Yagyu
February 19, 2016

Android CI: 2016 edition

DroidKaigi 2016 の発表資料です。

0c8f21e528a49d714bd0e1629054bdf4?s=128

Yusuke Yagyu

February 19, 2016
Tweet

More Decks by Yusuke Yagyu

Other Decks in Technology

Transcript

  1. ANDROID CI: 2016 EDITION YUSUKE YAGYU AT DROIDKAIGI 2016 DAY

    02
  2. ANDROID CI; 2016 EDITION ࣗݾ঺հ ▸ GMO ϖύϘגࣜձࣾ ٕज़෦ ٕज़ج൫νʔϜ

    ▸ ͍Ζ͍Ζ࡞͍ͬͯΖ͍Ζ௚͢ਓ݉ςετ͓͡͞Μ ▸ Android ΞϓϦ։ൃࣗମ͸ϝΠϯͰ͸ͳ͍Ͱ͢ ▸ ຖே࠷৽ͷ PHP / Ruby / Python3 ΛϏϧυ͢Δͷ͕ੜ͖͕ ͍
  3. ANDROID CI: 2016 EDITION ର৅ௌߨऀ ▸ ॳ৺ऀʙதڃऀ ▸ ΞϓϦ։ൃ͸Ͱ͖Δ͕ɺςετ͸Ͳ͔͜ΒखΛ͚͍͍ͭͯͷ ͔Θ͔Βͳ͍ํ

    ▸ യવͱςετ͸ॻ͚Δ͕ɺAndroidStudio Ͱ͔͠ςετͨ͠ ͜ͱ͕ͳ͍ਓ
  4. ANDROID CI: 2016 EDITION ຊ೔ͷςʔϚ ▸ ։ൃϑϩʔʹ͓͚Δ Android ςετͷ෼ྨ ▸

    Android ςετࣗಈԽͷϓϥϯχϯά ▸ Android ʹ͓͚Δ CI ͷϓϥϯχϯά ▸ Android CI ͷύλʔϯ
  5. ANDROID CI: 2016 EDITION DISCLAIMER ▸ ͜ͷεϐʔν͸2016೥2݄࣌఺ͷ৘ใͰ͋Γɺ͝ཡͷ࣌఺Ͱ ࠷৽ͷ৘ใͰ͋Δ͜ͱΛอূ͠·ͤΜ

  6. ANDROID CI; 2016 EDITION ࠷ॳʹେࣄͳ݁࿦Λ ▸ Android ։ൃʹݶΒͣɺࣗಈςετ / CI

    ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ
  7. ։ൃϑϩʔʹ͓͚Δ ANDROID ςετͷ෼ྨ

  8. ANDROID CI: 2016 EDITION ͓͞Β͍ɿҰൠతͳ։ൃϑϩʔ ▸ ʮҰൠతͳʯV ࣈ։ൃϞσϧ ▸ ཁ݅෼ੳˠجຊઃܭˠৄࡉઃܭˠ։ൃˠ

    ▸ ୯ମςετˠ݁߹ςετˠγεςϜςετˠडೖςετ
  9. ANDROID CI: 2016 EDITION ςετͷछྨͱࣗಈςετͷରԠ ▸ ୯ମςετɿUnit Test, Ұ෦ͷ Instrumentation

    Test ▸ ݁߹ςετɿ΄ͱΜͲͷ Instrumentation Test ▸ γεςϜɾडೖςετɿEnd-to-end Test ▸ ʢิ଍ʣ୳ࡧతςετɿओʹखಈʹΑΔ
  10. ANDROID CI: 2016 EDITION UNIT TEST ▸ app/src/test σΟϨΫτϦ ▸

    JVM / JUnit4 ϕʔεͷςετ ▸ ߴ଎ͳςετ ▸ Android SDK ґଘͷ෦෼͸ςετෆՄೳ
  11. ANDROID CI: 2016 EDITION INSTRUMENTATION TEST (ANDROID TEST) ▸ app/src/androidTest

    σΟϨΫτϦ ▸ ࣮ػɾΤϛϡϨʔλΛ࢖༻ͯ͠ͷςετ ▸ Android SDK ґଘͷίʔυ΋ςετՄೳ ▸ Activity ͷදࣔ΋ςετՄೳ
  12. ANDROID CI: 2016 EDITION INSTRUMENTATION TEST ͷϝϦοτ ▸ ֎෦ґଘʢe.g. Web

    API ίʔϧʣͷ͋ΔίʔυΛϞοΫԽ Մೳ ▸ ϞοΫԽ͢Δ͜ͱͰྫ֎ঢ়ଶͷςετ͕Մೳ
  13. ANDROID CI; 2016 EDITION INSTRUMENTATION TEST ͷ೉͠͞ ▸ e.g. Web

    API ίʔϧ͕ଘࡏ͢Δ৔߹ɺϞοΫ͞ΕͨϨεϙ ϯε͕࠷৽ͷ΋ͷͰ͋Δ͜ͱΛͲ͏୲อ͢Δʁ ▸ Fixture ϕʔεʹͯ͠ JSON Schema Ͱݕূ͢Δʁ ▸ μϛʔ API αʔόΛཱͯΔʁ
  14. ANDROID CI: 2016 EDITION END-TO-END TEST ▸ ϏϧυࡁΈͷ APK ʹର͢Δૢ࡞ςετ

    ▸ Πϯετʔϧࡁͷଞͷ APK ͱͷڠௐΛࢼݧ ▸ εΫϦʔϯγϣοτͷࡱӨ΋Մೳ
  15. ANDROID CI; 2016 EDITION END-TO-END TEST ͷ೉͠͞ ▸ e.g. Ͳ͜·ͰΛͯ͠

    End-to-end Test ͱఆٛ͢Δ͔ʁ ▸ Production αʔό΁઀ଓ͢Δʁ ▸ Build Flavor Λ࢖༻ͯ͠σόοά༻ API Λ࣋ͭݕূ༻αʔό ʹ઀ଓ͢Δʁ
  16. ANDROID ςετࣗಈ Խͷϓϥϯχϯά

  17. ANDROID CI: 2016 EDITION ANDROID ࣗಈςετͰසग़͢Δ୯ޠ ▸ JUnit ▸ Mockito

    ▸ Robolectric ▸ Espresso ▸ UI Automator ▸ Appium
  18. ANDROID CI: 2016 EDITION ROBOLECTRIC ▸ Unit Test ༻ͷ Android

    SDK shim ▸ JVM ্Ͱ͸ RuntimeException ʹͳΔ Android SDK ෦෼Λ shadow ʹࠩ͠ସ͑͢Δ ▸ Android SDK ґଘίʔυΛ Unit Test Մೳʹ͢Δ
  19. ANDROID CI: 2016 EDITION ROBOLECTRIC͸༗༻͔ʁ ▸ ʮ෦෼తʹ͸ʯ༗༻ ▸ Bundle, Intent

    ͸୯७ͳ Map ͱͯ͠ར༻Մೳ ▸ AsyncTaskLoader ͷಉظԽ ▸ ͦΕҎ֎ͷʢಛʹ୺຤݁߹౓ߴ͍ʣ API ͸੬͍
  20. ANDROID CI: 2016 EDITION MOCKITO ▸ Unit Test, Instrumentation Test

    Ͱ࢖͑ΔϞοΫϥΠϒϥϦ ▸ ଞʹ΋ީิ͸͋Δ ▸ Spy, Stub ͷҧ͍ʹ஫ҙ
  21. ANDROID CI: 2016 EDITION ESPRESSO ▸ Instrumentation Test ͷߴϨϕϧϥούʔ ▸

    ඇಉظͳ Activity ͷςετΛಉظతʹॻ͚Δ ▸ Testing Support Library ͷҰ෦
  22. ANDROID CI: 2016 EDITION UI AUTOMATOR ▸ End-to-end Test πʔϧ

    ▸ Testing Support Library ͷҰ෦ ▸ Android OS >= 4.1
  23. ANDROID CI: 2016 EDITION APPIUM ▸ Selenium ޓ׵ͷ End-to-end ςετπʔϧ

    ▸ Java, JavaScript (Node), .NET, PHP, Python, Ruby, Perl ͳͲ ݴޠΛ໰Θͣςετίʔυ͕ॻ͚Δ
  24. ANDROID CI: 2016 EDITION ςετϑΣʔζͱπʔϧબఆ ▸ ςετΛαϙʔτ͢ΔπʔϧΛબఆ͢Δ ▸ End-to-end Test

    πʔϧબఆ͸ཁߟྀ ▸ Testing Support Library ͸మ൘
  25. ANDROID CI: 2016 EDITION ςετࣗಈԽͷηΦϦʔ ▸ ࣮ߦ଎౓͸୯ମʼ݁߹ʼडೖͷॱʹ஗͘ͳΔ ▸ ͭ·Γέʔε਺͸୯ମʼ݁߹ʼडೖͷॱʹ͢Δͷ͕ϕετ ▸

    ͜Ε͸ Android ։ൃʹ͍ͭͯ΋ಉ༷ͷ͜ͱ͸ݴ͑Δ
  26. ANDROID CI: 2016 EDITION ςετΛͲ͏ࣗಈԽ͢Δ͔ʁ ▸ ՔಇதͷΞϓϦ͕͋Δ৔߹ͱ৽ن։ൃͷ৔߹ͰมԽ ▸ Քಇதͷ৔߹ɿ Instrumentation

    Test / End-to-end Test ͰՔ ಇΛ୲อ͠ͳ͕ΒϦϑΝΫλϦϯά ▸ ৽ن։ൃͷ৔߹ɿ MVP Architecture ͳͲͰ SDK ͔Βϩδο ΫΛ੾Γ཭͠ Unit Test Λް͘͢Δ
  27. ANDROID CI: 2016 EDITION Ͳ͜·ͰςετΛॻ͘΂͖͔ʁ ▸ ԾʹΧόϨοδ 100% ͩͬͨͱͯ͠΋૝ఆ࿙Ε͕ൃੜ͢Δ ▸

    End-to-end Test Ͱϋοϐʔύεʢ੒ޭύλʔϯʣҎ֎Λॻ ͘͜ͱ͸೉͍͠ ▸ ʮ҆৺͢Δ·ͰςετΛॻ͘ʯ(@ahomu)
  28. ANDROID CI: 2016 EDITION ٯʹݴ͑͹ ▸ End-to-end Test ͚ͩΛॻ͍ͯʮಈ͘͜ͱ͚ͩʯ͸୲อ͢Δ ͷ΋Ұͭͷख

    ▸ ςετͷϓϥϯχϯά͸ਓతϦιʔεͷଟՉɺϝϯόʔͷٕ ज़ྗɺϦϦʔε·Ͱͷ࢒Γ࣌ؒʹج͍ͮͯಋग़͢Δ
  29. ANDROID CI: 2016 EDITION ॏཁͳͷ͸ ▸ νʔϜͷϝϯόʔશһ͕ࣗಈςετͷॏཁ͞Λ࣮ײ͢Δ͜ͱ ▸ νʔϜͷ։ൃऀશһ͕࣮ࡍʹखΛಈ͔ͯ͠ςετίʔυΛॻ ͚ΔΑ͏ʹͳΔ͜ͱ

    ▸ ςετίʔυΛॻ͘ͷ͕೉͍͠෦෼Λ੾Γ෼͚ΒΕΔʮςε τʹڧ͍ΤϯδχΞʯ͕͍Δͱͳ͓Α͍
  30. ANDROID ʹ͓͚Δ CI ͷϓϥϯχϯά

  31. ANDROID CI: 2016 EDITION Ωʔϫʔυ ▸ Jenkins ▸ ίϯςφϕʔε CI

    αʔϏε ▸ Device Farm ▸ Smartphone Test Farm
  32. ANDROID CI: 2016 EDITION JENKINS ▸ Jenkins + Git Plugin

    / GitHub Plugin ▸ αʔόߏ੒ΛίϯτϩʔϧՄೳʹ࣮ػ઀ଓՄೳ ▸ Unit Test, Instrumentation Test, End-to-end Test શͯΧόʔ ▸ ʮJenkins ৬ਓʯ໰୊
  33. ANDROID CI: 2016 EDITION ίϯςφϕʔε CI ▸ e.g. Travis CI,

    Circle CI, Drone, Wercker… ▸ ൺֱత҆Ձʢ̌ԁʙʣͰςετՄೳ ▸ JVM ϕʔεͷߴ଎ςετΛಘҙͱ͢Δ ▸ Activity Test / End-to-End Test Λߦ͏ͳΒผͷ࢓૊Έ͕ඞཁ
  34. ANDROID CI: 2016 EDITION DEVICE FARM ▸ ෳ਺ͷ࣮ػʢ୺຤ɺOSόʔδϣϯʣΛςετ࣮ߦ؀ڥͱ͠ ͯ࢖͑Δ ▸

    ಠࣗςετ DSL, Web ϕʔεͷը໘ૢ࡞ͳͲ ▸ DFaaS (Device Farm as a Service) ΁ͷ Amazon / Google ࢀೖʢGoogle Cloud Test Lab ͸ Closed Test தʣ
  35. ANDROID CI: 2016 EDITION CI ޲͚ DFAAS ͷબఆج४ ▸ طଘͷςετࢿ࢈

    (Instrumentation Test, End-to-end Test) ͕࢖͑Δ͔ʁ ▸ Jenkins Plugin ͕༻ҙ͞Ε͍ͯΔ͔ʁ ▸ Gradle Plugin ͕༻ҙ͞Ε͍ͯΔ͔ʁ ▸ Web API ͕༻ҙ͞Ε͍ͯΔ͔ʁ
  36. ANDROID CI: 2016 EDITION SMARTPHONE TEST FARM (STF) ▸ Device

    Farm Λ in-house Ͱ࣋ͭπʔϧ ▸ Device Farm ͷඪ४తͳػೳΛҰ௨Γ࣋ͭ ▸ adb connect ʹΑΔϦϞʔτσόοά
  37. ANDROID CI: 2016 EDITION STF 2.0 ▸ REST APIʢ୺຤ঢ়ଶɺ୺຤ϩοΫऔಘʣͷ௥Ճ ▸

    ΑΓࣗಈςετͱ਌࿨ੑͷߴ͍ػೳΛऔಘ
  38. ANDROID CI: 2016 EDITION CI Λલఏͱͨ͠ςετΛॻ͘ ▸ ςετલޙͰ୺຤ͷঢ়ଶ͕มΘΒͳ͍͜ͱΛ୲อ͢Δ ▸ ΤϛϡϨʔλΛഁغ͢Δɺ୺຤ΛϫΠϓ͢ΔͳͲ

    ▸ ୯ମʼ݁߹ʼडೖͷέʔε਺ηΦϦʔΛकΒͳ͍ͱɺ͙͢ʹ ࣮ߦ͕࣌ؒരൃతʹ௕͘ͳΔ
  39. ANDROID CI: 2016 EDITION ϓϥϯχϯάઓज़ ▸ Jenkins Λϝϯςφϯε͢ΔਓతϦιʔε͕֬อͰ͖ΔͷͰ ͋Ε͹ɺJenkins ▸

    Jenkins Λϝϯςφϯε͢ΔਓతίετΛ DFaaS ར༻ྉʹ సԽͰ͖ΔͳΒɺίϯςφϕʔε CI + DFaaS
  40. ANDROID CI: 2016 EDITION େࣄͳͷ͸ ▸ CI Λߦ͏͜ͱͰࣗಈςετΛश׳Խ͠ɺ඼࣭ΛԼ͛ͳ͍͜ ͱΛνʔϜͷϝϯόʔશһͰ߹ҙ͢Δ͜ͱ ▸

    ݱ࣌఺Ͱ͸ Device Farm ΋ա౉ظʹ͋Γɺಛఆͷϓϥοτ ϑΥʔϜʹա৒ʹґଘ͢ΔͱɺϨΨγʔԽ͢ΔϦεΫΛ๊͑ Δ
  41. ANDROID CIͷύ λʔϯ

  42. ANDROID CI: 2016 EDITION ύλʔϯ̍ ▸ Jenkins + ࣮ػ઀ଓʢ΋͘͠͸ΤϛϡϨʔλʣ ▸

    ࠷΋γϯϓϧͳߏ੒ ▸ ༨ΓϦιʔεͰελʔτͰ͖Δͱ͍͏ख͕ܰ͋͞Δ ▸ ୺຤ͷଟ༷Խʹ͸खಈͰ௥ਵ͠ͳ͚Ε͹ͳΒͳ͍
  43. ANDROID CI: 2016 EDITION ύλʔϯ̎ ▸ Jenkins + (Docker) +

    STF + ࣮ػ઀ଓ ▸ γϯϓϧͳߏ੒Λ֦ுͯ͠ɺ୺຤ͷଟ༷ੑʹ௥ਵՄೳʹͨ͠ ύλʔϯ ▸ ୺຤Λ༻ҙ͢Δίετͱϝϯςφϯεʹ͔͔ΔਓతϦιʔε ͕՝୊
  44. ANDROID CI: 2016 EDITION ύλʔϯ̏ ▸ ίϯςφϕʔε CI αʔϏε +

    DFaaS ▸ ϝϯςφϯεϑϦʔͳ CI ύλʔϯ ▸ DFaaS ͷอ࣋͢Δ୺຤ʹ੍໿Λड͚Δ
  45. ANDROID CI: 2016 EDITION ฐࣾʹ͓͚Δ CI ͷ࠾༻ঢ়گ ▸ minne ϞόΠϧΞϓϦʹ

    CI ಋೖ ▸ ύλʔϯ̎ͱύλʔϯ̏Λซ༻͠ɺൺֱݕ౼த
  46. ANDROID CI: 2016 EDITION ݁࿦Λ܁Γฦ͠ ▸ Android ։ൃʹݶΒͣɺࣗಈςετ / CI

    ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ
  47. ANDROID CI: 2016 EDITION ൃද͸Ҏ্Ͱ͢ ▸ ͋Γ͕ͱ͏͍͟͝·ͨ͠