$30 off During Our Annual Pro Sale. View Details »

Android CI: 2016 edition

Yusuke Yagyu
February 19, 2016

Android CI: 2016 edition

DroidKaigi 2016 の発表資料です。

Yusuke Yagyu

February 19, 2016
Tweet

More Decks by Yusuke Yagyu

Other Decks in Technology

Transcript

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

    ▸ ͍Ζ͍Ζ࡞͍ͬͯΖ͍Ζ௚͢ਓ݉ςετ͓͡͞Μ ▸ Android ΞϓϦ։ൃࣗମ͸ϝΠϯͰ͸ͳ͍Ͱ͢ ▸ ຖே࠷৽ͷ PHP / Ruby / Python3 ΛϏϧυ͢Δͷ͕ੜ͖͕ ͍
  2. ANDROID CI: 2016 EDITION ຊ೔ͷςʔϚ ▸ ։ൃϑϩʔʹ͓͚Δ Android ςετͷ෼ྨ ▸

    Android ςετࣗಈԽͷϓϥϯχϯά ▸ Android ʹ͓͚Δ CI ͷϓϥϯχϯά ▸ Android CI ͷύλʔϯ
  3. ANDROID CI; 2016 EDITION ࠷ॳʹେࣄͳ݁࿦Λ ▸ Android ։ൃʹݶΒͣɺࣗಈςετ / CI

    ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ
  4. ANDROID CI: 2016 EDITION ςετͷछྨͱࣗಈςετͷରԠ ▸ ୯ମςετɿUnit Test, Ұ෦ͷ Instrumentation

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

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

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

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

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

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

    End-to-end Test ͱఆٛ͢Δ͔ʁ ▸ Production αʔό΁઀ଓ͢Δʁ ▸ Build Flavor Λ࢖༻ͯ͠σόοά༻ API Λ࣋ͭݕূ༻αʔό ʹ઀ଓ͢Δʁ
  11. ANDROID CI: 2016 EDITION ANDROID ࣗಈςετͰසग़͢Δ୯ޠ ▸ JUnit ▸ Mockito

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

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

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

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

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

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

    ▸ Java, JavaScript (Node), .NET, PHP, Python, Ruby, Perl ͳͲ ݴޠΛ໰Θͣςετίʔυ͕ॻ͚Δ
  18. ANDROID CI: 2016 EDITION ςετΛͲ͏ࣗಈԽ͢Δ͔ʁ ▸ ՔಇதͷΞϓϦ͕͋Δ৔߹ͱ৽ن։ൃͷ৔߹ͰมԽ ▸ Քಇதͷ৔߹ɿ Instrumentation

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

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

    ▸ ςετͷϓϥϯχϯά͸ਓతϦιʔεͷଟՉɺϝϯόʔͷٕ ज़ྗɺϦϦʔε·Ͱͷ࢒Γ࣌ؒʹج͍ͮͯಋग़͢Δ
  21. ANDROID CI: 2016 EDITION Ωʔϫʔυ ▸ Jenkins ▸ ίϯςφϕʔε CI

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

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

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

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

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

    Farm Λ in-house Ͱ࣋ͭπʔϧ ▸ Device Farm ͷඪ४తͳػೳΛҰ௨Γ࣋ͭ ▸ adb connect ʹΑΔϦϞʔτσόοά
  27. ANDROID CI: 2016 EDITION ϓϥϯχϯάઓज़ ▸ Jenkins Λϝϯςφϯε͢ΔਓతϦιʔε͕֬อͰ͖ΔͷͰ ͋Ε͹ɺJenkins ▸

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

    ݱ࣌఺Ͱ͸ Device Farm ΋ա౉ظʹ͋Γɺಛఆͷϓϥοτ ϑΥʔϜʹա৒ʹґଘ͢ΔͱɺϨΨγʔԽ͢ΔϦεΫΛ๊͑ Δ
  29. ANDROID CI: 2016 EDITION ύλʔϯ̍ ▸ Jenkins + ࣮ػ઀ଓʢ΋͘͠͸ΤϛϡϨʔλʣ ▸

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

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

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

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

    ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ