Slide 1

Slide 1 text

ANDROID CI: 2016 EDITION YUSUKE YAGYU AT DROIDKAIGI 2016 DAY 02

Slide 2

Slide 2 text

ANDROID CI; 2016 EDITION ࣗݾ঺հ ▸ GMO ϖύϘגࣜձࣾ ٕज़෦ ٕज़ج൫νʔϜ ▸ ͍Ζ͍Ζ࡞͍ͬͯΖ͍Ζ௚͢ਓ݉ςετ͓͡͞Μ ▸ Android ΞϓϦ։ൃࣗମ͸ϝΠϯͰ͸ͳ͍Ͱ͢ ▸ ຖே࠷৽ͷ PHP / Ruby / Python3 ΛϏϧυ͢Δͷ͕ੜ͖͕ ͍

Slide 3

Slide 3 text

ANDROID CI: 2016 EDITION ର৅ௌߨऀ ▸ ॳ৺ऀʙதڃऀ ▸ ΞϓϦ։ൃ͸Ͱ͖Δ͕ɺςετ͸Ͳ͔͜ΒखΛ͚͍͍ͭͯͷ ͔Θ͔Βͳ͍ํ ▸ യવͱςετ͸ॻ͚Δ͕ɺAndroidStudio Ͱ͔͠ςετͨ͠ ͜ͱ͕ͳ͍ਓ

Slide 4

Slide 4 text

ANDROID CI: 2016 EDITION ຊ೔ͷςʔϚ ▸ ։ൃϑϩʔʹ͓͚Δ Android ςετͷ෼ྨ ▸ Android ςετࣗಈԽͷϓϥϯχϯά ▸ Android ʹ͓͚Δ CI ͷϓϥϯχϯά ▸ Android CI ͷύλʔϯ

Slide 5

Slide 5 text

ANDROID CI: 2016 EDITION DISCLAIMER ▸ ͜ͷεϐʔν͸2016೥2݄࣌఺ͷ৘ใͰ͋Γɺ͝ཡͷ࣌఺Ͱ ࠷৽ͷ৘ใͰ͋Δ͜ͱΛอূ͠·ͤΜ

Slide 6

Slide 6 text

ANDROID CI; 2016 EDITION ࠷ॳʹେࣄͳ݁࿦Λ ▸ Android ։ൃʹݶΒͣɺࣗಈςετ / CI ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ

Slide 7

Slide 7 text

։ൃϑϩʔʹ͓͚Δ ANDROID ςετͷ෼ྨ

Slide 8

Slide 8 text

ANDROID CI: 2016 EDITION ͓͞Β͍ɿҰൠతͳ։ൃϑϩʔ ▸ ʮҰൠతͳʯV ࣈ։ൃϞσϧ ▸ ཁ݅෼ੳˠجຊઃܭˠৄࡉઃܭˠ։ൃˠ ▸ ୯ମςετˠ݁߹ςετˠγεςϜςετˠडೖςετ

Slide 9

Slide 9 text

ANDROID CI: 2016 EDITION ςετͷछྨͱࣗಈςετͷରԠ ▸ ୯ମςετɿUnit Test, Ұ෦ͷ Instrumentation Test ▸ ݁߹ςετɿ΄ͱΜͲͷ Instrumentation Test ▸ γεςϜɾडೖςετɿEnd-to-end Test ▸ ʢิ଍ʣ୳ࡧతςετɿओʹखಈʹΑΔ

Slide 10

Slide 10 text

ANDROID CI: 2016 EDITION UNIT TEST ▸ app/src/test σΟϨΫτϦ ▸ JVM / JUnit4 ϕʔεͷςετ ▸ ߴ଎ͳςετ ▸ Android SDK ґଘͷ෦෼͸ςετෆՄೳ

Slide 11

Slide 11 text

ANDROID CI: 2016 EDITION INSTRUMENTATION TEST (ANDROID TEST) ▸ app/src/androidTest σΟϨΫτϦ ▸ ࣮ػɾΤϛϡϨʔλΛ࢖༻ͯ͠ͷςετ ▸ Android SDK ґଘͷίʔυ΋ςετՄೳ ▸ Activity ͷදࣔ΋ςετՄೳ

Slide 12

Slide 12 text

ANDROID CI: 2016 EDITION INSTRUMENTATION TEST ͷϝϦοτ ▸ ֎෦ґଘʢe.g. Web API ίʔϧʣͷ͋ΔίʔυΛϞοΫԽ Մೳ ▸ ϞοΫԽ͢Δ͜ͱͰྫ֎ঢ়ଶͷςετ͕Մೳ

Slide 13

Slide 13 text

ANDROID CI; 2016 EDITION INSTRUMENTATION TEST ͷ೉͠͞ ▸ e.g. Web API ίʔϧ͕ଘࡏ͢Δ৔߹ɺϞοΫ͞ΕͨϨεϙ ϯε͕࠷৽ͷ΋ͷͰ͋Δ͜ͱΛͲ͏୲อ͢Δʁ ▸ Fixture ϕʔεʹͯ͠ JSON Schema Ͱݕূ͢Δʁ ▸ μϛʔ API αʔόΛཱͯΔʁ

Slide 14

Slide 14 text

ANDROID CI: 2016 EDITION END-TO-END TEST ▸ ϏϧυࡁΈͷ APK ʹର͢Δૢ࡞ςετ ▸ Πϯετʔϧࡁͷଞͷ APK ͱͷڠௐΛࢼݧ ▸ εΫϦʔϯγϣοτͷࡱӨ΋Մೳ

Slide 15

Slide 15 text

ANDROID CI; 2016 EDITION END-TO-END TEST ͷ೉͠͞ ▸ e.g. Ͳ͜·ͰΛͯ͠ End-to-end Test ͱఆٛ͢Δ͔ʁ ▸ Production αʔό΁઀ଓ͢Δʁ ▸ Build Flavor Λ࢖༻ͯ͠σόοά༻ API Λ࣋ͭݕূ༻αʔό ʹ઀ଓ͢Δʁ

Slide 16

Slide 16 text

ANDROID ςετࣗಈ Խͷϓϥϯχϯά

Slide 17

Slide 17 text

ANDROID CI: 2016 EDITION ANDROID ࣗಈςετͰසग़͢Δ୯ޠ ▸ JUnit ▸ Mockito ▸ Robolectric ▸ Espresso ▸ UI Automator ▸ Appium

Slide 18

Slide 18 text

ANDROID CI: 2016 EDITION ROBOLECTRIC ▸ Unit Test ༻ͷ Android SDK shim ▸ JVM ্Ͱ͸ RuntimeException ʹͳΔ Android SDK ෦෼Λ shadow ʹࠩ͠ସ͑͢Δ ▸ Android SDK ґଘίʔυΛ Unit Test Մೳʹ͢Δ

Slide 19

Slide 19 text

ANDROID CI: 2016 EDITION ROBOLECTRIC͸༗༻͔ʁ ▸ ʮ෦෼తʹ͸ʯ༗༻ ▸ Bundle, Intent ͸୯७ͳ Map ͱͯ͠ར༻Մೳ ▸ AsyncTaskLoader ͷಉظԽ ▸ ͦΕҎ֎ͷʢಛʹ୺຤݁߹౓ߴ͍ʣ API ͸੬͍

Slide 20

Slide 20 text

ANDROID CI: 2016 EDITION MOCKITO ▸ Unit Test, Instrumentation Test Ͱ࢖͑ΔϞοΫϥΠϒϥϦ ▸ ଞʹ΋ީิ͸͋Δ ▸ Spy, Stub ͷҧ͍ʹ஫ҙ

Slide 21

Slide 21 text

ANDROID CI: 2016 EDITION ESPRESSO ▸ Instrumentation Test ͷߴϨϕϧϥούʔ ▸ ඇಉظͳ Activity ͷςετΛಉظతʹॻ͚Δ ▸ Testing Support Library ͷҰ෦

Slide 22

Slide 22 text

ANDROID CI: 2016 EDITION UI AUTOMATOR ▸ End-to-end Test πʔϧ ▸ Testing Support Library ͷҰ෦ ▸ Android OS >= 4.1

Slide 23

Slide 23 text

ANDROID CI: 2016 EDITION APPIUM ▸ Selenium ޓ׵ͷ End-to-end ςετπʔϧ ▸ Java, JavaScript (Node), .NET, PHP, Python, Ruby, Perl ͳͲ ݴޠΛ໰Θͣςετίʔυ͕ॻ͚Δ

Slide 24

Slide 24 text

ANDROID CI: 2016 EDITION ςετϑΣʔζͱπʔϧબఆ ▸ ςετΛαϙʔτ͢ΔπʔϧΛબఆ͢Δ ▸ End-to-end Test πʔϧબఆ͸ཁߟྀ ▸ Testing Support Library ͸మ൘

Slide 25

Slide 25 text

ANDROID CI: 2016 EDITION ςετࣗಈԽͷηΦϦʔ ▸ ࣮ߦ଎౓͸୯ମʼ݁߹ʼडೖͷॱʹ஗͘ͳΔ ▸ ͭ·Γέʔε਺͸୯ମʼ݁߹ʼडೖͷॱʹ͢Δͷ͕ϕετ ▸ ͜Ε͸ Android ։ൃʹ͍ͭͯ΋ಉ༷ͷ͜ͱ͸ݴ͑Δ

Slide 26

Slide 26 text

ANDROID CI: 2016 EDITION ςετΛͲ͏ࣗಈԽ͢Δ͔ʁ ▸ ՔಇதͷΞϓϦ͕͋Δ৔߹ͱ৽ن։ൃͷ৔߹ͰมԽ ▸ Քಇதͷ৔߹ɿ Instrumentation Test / End-to-end Test ͰՔ ಇΛ୲อ͠ͳ͕ΒϦϑΝΫλϦϯά ▸ ৽ن։ൃͷ৔߹ɿ MVP Architecture ͳͲͰ SDK ͔Βϩδο ΫΛ੾Γ཭͠ Unit Test Λް͘͢Δ

Slide 27

Slide 27 text

ANDROID CI: 2016 EDITION Ͳ͜·ͰςετΛॻ͘΂͖͔ʁ ▸ ԾʹΧόϨοδ 100% ͩͬͨͱͯ͠΋૝ఆ࿙Ε͕ൃੜ͢Δ ▸ End-to-end Test Ͱϋοϐʔύεʢ੒ޭύλʔϯʣҎ֎Λॻ ͘͜ͱ͸೉͍͠ ▸ ʮ҆৺͢Δ·ͰςετΛॻ͘ʯ(@ahomu)

Slide 28

Slide 28 text

ANDROID CI: 2016 EDITION ٯʹݴ͑͹ ▸ End-to-end Test ͚ͩΛॻ͍ͯʮಈ͘͜ͱ͚ͩʯ͸୲อ͢Δ ͷ΋Ұͭͷख ▸ ςετͷϓϥϯχϯά͸ਓతϦιʔεͷଟՉɺϝϯόʔͷٕ ज़ྗɺϦϦʔε·Ͱͷ࢒Γ࣌ؒʹج͍ͮͯಋग़͢Δ

Slide 29

Slide 29 text

ANDROID CI: 2016 EDITION ॏཁͳͷ͸ ▸ νʔϜͷϝϯόʔશһ͕ࣗಈςετͷॏཁ͞Λ࣮ײ͢Δ͜ͱ ▸ νʔϜͷ։ൃऀશһ͕࣮ࡍʹखΛಈ͔ͯ͠ςετίʔυΛॻ ͚ΔΑ͏ʹͳΔ͜ͱ ▸ ςετίʔυΛॻ͘ͷ͕೉͍͠෦෼Λ੾Γ෼͚ΒΕΔʮςε τʹڧ͍ΤϯδχΞʯ͕͍Δͱͳ͓Α͍

Slide 30

Slide 30 text

ANDROID ʹ͓͚Δ CI ͷϓϥϯχϯά

Slide 31

Slide 31 text

ANDROID CI: 2016 EDITION Ωʔϫʔυ ▸ Jenkins ▸ ίϯςφϕʔε CI αʔϏε ▸ Device Farm ▸ Smartphone Test Farm

Slide 32

Slide 32 text

ANDROID CI: 2016 EDITION JENKINS ▸ Jenkins + Git Plugin / GitHub Plugin ▸ αʔόߏ੒ΛίϯτϩʔϧՄೳʹ࣮ػ઀ଓՄೳ ▸ Unit Test, Instrumentation Test, End-to-end Test શͯΧόʔ ▸ ʮJenkins ৬ਓʯ໰୊

Slide 33

Slide 33 text

ANDROID CI: 2016 EDITION ίϯςφϕʔε CI ▸ e.g. Travis CI, Circle CI, Drone, Wercker… ▸ ൺֱత҆Ձʢ̌ԁʙʣͰςετՄೳ ▸ JVM ϕʔεͷߴ଎ςετΛಘҙͱ͢Δ ▸ Activity Test / End-to-End Test Λߦ͏ͳΒผͷ࢓૊Έ͕ඞཁ

Slide 34

Slide 34 text

ANDROID CI: 2016 EDITION DEVICE FARM ▸ ෳ਺ͷ࣮ػʢ୺຤ɺOSόʔδϣϯʣΛςετ࣮ߦ؀ڥͱ͠ ͯ࢖͑Δ ▸ ಠࣗςετ DSL, Web ϕʔεͷը໘ૢ࡞ͳͲ ▸ DFaaS (Device Farm as a Service) ΁ͷ Amazon / Google ࢀೖʢGoogle Cloud Test Lab ͸ Closed Test தʣ

Slide 35

Slide 35 text

ANDROID CI: 2016 EDITION CI ޲͚ DFAAS ͷબఆج४ ▸ طଘͷςετࢿ࢈ (Instrumentation Test, End-to-end Test) ͕࢖͑Δ͔ʁ ▸ Jenkins Plugin ͕༻ҙ͞Ε͍ͯΔ͔ʁ ▸ Gradle Plugin ͕༻ҙ͞Ε͍ͯΔ͔ʁ ▸ Web API ͕༻ҙ͞Ε͍ͯΔ͔ʁ

Slide 36

Slide 36 text

ANDROID CI: 2016 EDITION SMARTPHONE TEST FARM (STF) ▸ Device Farm Λ in-house Ͱ࣋ͭπʔϧ ▸ Device Farm ͷඪ४తͳػೳΛҰ௨Γ࣋ͭ ▸ adb connect ʹΑΔϦϞʔτσόοά

Slide 37

Slide 37 text

ANDROID CI: 2016 EDITION STF 2.0 ▸ REST APIʢ୺຤ঢ়ଶɺ୺຤ϩοΫऔಘʣͷ௥Ճ ▸ ΑΓࣗಈςετͱ਌࿨ੑͷߴ͍ػೳΛऔಘ

Slide 38

Slide 38 text

ANDROID CI: 2016 EDITION CI Λલఏͱͨ͠ςετΛॻ͘ ▸ ςετલޙͰ୺຤ͷঢ়ଶ͕มΘΒͳ͍͜ͱΛ୲อ͢Δ ▸ ΤϛϡϨʔλΛഁغ͢Δɺ୺຤ΛϫΠϓ͢ΔͳͲ ▸ ୯ମʼ݁߹ʼडೖͷέʔε਺ηΦϦʔΛकΒͳ͍ͱɺ͙͢ʹ ࣮ߦ͕࣌ؒരൃతʹ௕͘ͳΔ

Slide 39

Slide 39 text

ANDROID CI: 2016 EDITION ϓϥϯχϯάઓज़ ▸ Jenkins Λϝϯςφϯε͢ΔਓతϦιʔε͕֬อͰ͖ΔͷͰ ͋Ε͹ɺJenkins ▸ Jenkins Λϝϯςφϯε͢ΔਓతίετΛ DFaaS ར༻ྉʹ సԽͰ͖ΔͳΒɺίϯςφϕʔε CI + DFaaS

Slide 40

Slide 40 text

ANDROID CI: 2016 EDITION େࣄͳͷ͸ ▸ CI Λߦ͏͜ͱͰࣗಈςετΛश׳Խ͠ɺ඼࣭ΛԼ͛ͳ͍͜ ͱΛνʔϜͷϝϯόʔશһͰ߹ҙ͢Δ͜ͱ ▸ ݱ࣌఺Ͱ͸ Device Farm ΋ա౉ظʹ͋Γɺಛఆͷϓϥοτ ϑΥʔϜʹա৒ʹґଘ͢ΔͱɺϨΨγʔԽ͢ΔϦεΫΛ๊͑ Δ

Slide 41

Slide 41 text

ANDROID CIͷύ λʔϯ

Slide 42

Slide 42 text

ANDROID CI: 2016 EDITION ύλʔϯ̍ ▸ Jenkins + ࣮ػ઀ଓʢ΋͘͠͸ΤϛϡϨʔλʣ ▸ ࠷΋γϯϓϧͳߏ੒ ▸ ༨ΓϦιʔεͰελʔτͰ͖Δͱ͍͏ख͕ܰ͋͞Δ ▸ ୺຤ͷଟ༷Խʹ͸खಈͰ௥ਵ͠ͳ͚Ε͹ͳΒͳ͍

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

ANDROID CI: 2016 EDITION ύλʔϯ̏ ▸ ίϯςφϕʔε CI αʔϏε + DFaaS ▸ ϝϯςφϯεϑϦʔͳ CI ύλʔϯ ▸ DFaaS ͷอ࣋͢Δ୺຤ʹ੍໿Λड͚Δ

Slide 45

Slide 45 text

ANDROID CI: 2016 EDITION ฐࣾʹ͓͚Δ CI ͷ࠾༻ঢ়گ ▸ minne ϞόΠϧΞϓϦʹ CI ಋೖ ▸ ύλʔϯ̎ͱύλʔϯ̏Λซ༻͠ɺൺֱݕ౼த

Slide 46

Slide 46 text

ANDROID CI: 2016 EDITION ݁࿦Λ܁Γฦ͠ ▸ Android ։ൃʹݶΒͣɺࣗಈςετ / CI ͸Ͳ͜ΛऔΔ͔ɺͲ ͜Λ੾ΓࣺͯΔ͔ɺҰछͷՁ஋൑அͰ͋Δ ▸ ൑அج४ͱͯ͠͸ɺٕज़త੍໿ɺਓతϦιʔεɺ࣌ؒత੍໿ɺ ༧ࢉͷ੍໿͕ڍ͛ΒΕΔ

Slide 47

Slide 47 text

ANDROID CI: 2016 EDITION ൃද͸Ҏ্Ͱ͢ ▸ ͋Γ͕ͱ͏͍͟͝·ͨ͠