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

アプリのユニットテストについて初歩から考えてみる/ABC UnitTest

アプリのユニットテストについて初歩から考えてみる/ABC UnitTest

2017/10/02 俺コン Vol.1 / Day.1

11418f445034320fbcf7b531f7ae34a2?s=128

Koichiro Oishi

October 03, 2017
Tweet

More Decks by Koichiro Oishi

Other Decks in Programming

Transcript

  1. ΞϓϦͷϢχοτςετʹͭ ͍ͯॳา͔Βߟ͑ͯΈΔ 2017/10/02 Զίϯ Vol.1 / Day.1 େੴ ߂Ұ࿠ɹ(@mego_, Koishi)

    1 Koichiro Oishi, 2017/10/02
  2. ࣗݾ঺հ • େੴ ߂Ұ࿠ • iOSΞϓϦΤϯδχΞ • גࣜձࣾϚφϘ →9݄ʹSIer͔Βస৬͠·͠ ͨʂ

    2 Koichiro Oishi, 2017/10/02
  3. ຊ೔ͷ͓୊ • ΞϓϦͷϢχοτςετΛͳΜͱͳ͘ॻ͍ͯΔ • Xcodeඪ४ͷXCTestΛ࢖༻ • ओʹϞσϧ෦෼ͷΈ • ௨৴ॲཧ͸։ൃαʔόͱ௨৴͢Δςετ •

    UIςετ͸ϊʔλον 3 Koichiro Oishi, 2017/10/02
  4. 4 Koichiro Oishi, 2017/10/02

  5. ৭ʑؾʹͳΔ͜ͱ΋͋ͬͯɺ ৄ͍͠ਓʹฉ͍ͯΈ͍ͨ 5 Koichiro Oishi, 2017/10/02

  6. ͱ͍͏͜ͱͰɺςετʹৄ͠ ͍ਓʹฉ͍ͯߟ͑ͯΈ·ͨ͠ (લ৬ͷݱ৔Ͱͷ࿩) 6 Koichiro Oishi, 2017/10/02

  7. ςετʹৄ͍͠ํͱ͍͑͹͋ ͷํͰ͢Ͷʂ 7 Koichiro Oishi, 2017/10/02

  8. ͜Μͳ͜ͱΛฉ͖·ͨ͠ • Modelͷςετ͸͜Μͳ෩ʹॻ͍ͯΔ͚Ͳʁ • ௨৴෦෼͸։ൃαʔόͱ௨৴ͯ͠Δ͚ͲMockΛ ࢖ͬͨํ͕ྑ͍ʁ • Viewͷςετ͸Ͳ͏͢Ε͹ྑ͍ʁ • ΧόϨοδʹ͍ͭͯ

    8 Koichiro Oishi, 2017/10/02
  9. Modelͷςετ͍·͜Μͳ෩ ʹॻ͍ͯ·͚͢ͲͲ͏Ͱ͢ ͔ʁ 9 Koichiro Oishi, 2017/10/02

  10. ͜Μͳ෩ʹॻ͍͍ͯ·ͨ͠ɻ 10 Koichiro Oishi, 2017/10/02

  11. →ϝιου໊͸ྑ͍ ঢ়ଶͱظ଴͞ΕΔ݁Ռ͕ϝιου໊ʹॻ͔Ε͍ͯΔ 11 Koichiro Oishi, 2017/10/02

  12. →ಉ͡ΫϥεͷςετͰ΋ά ϧʔϓԽͨ͠ΒΑ͍ • JUnitͰ͍͏Enclosed • RspecͰ͍͏describe →XCTestͩͱͰ͖ͳ͍ →QuickͩͱͰ͖ΔͬΆ͍? 12 Koichiro

    Oishi, 2017/10/02
  13. →ΫϥεͱςετΫϥε͸1 ରଟͰΑ͍ 13 Koichiro Oishi, 2017/10/02

  14. ௨৴෦෼͸։ൃαʔόͱ௨৴ ͯ͠Δ͚ͲMockΛ࢖ͬͨํ ͕ྑ͍ʁ 14 Koichiro Oishi, 2017/10/02

  15. →ඞͣ͠΋࢖Θͳͯ͘ྑ͍ • MockΛ࢖͏ͱɺMock͕ਖ਼͍͠࢓༷Ͱ͋Δ͜ͱͷ ୲อ͕ඞཁʹͳΔ • ςετʹ࢖͑Δ։ൃαʔό͕͋Ε͹ͦͪΒͷํ͕ ௿ίετ • ؀ڥతʹ௨৴Ͱ͖ͳ͍ɺ͕͔͔࣌ؒΔͱ͍ͬͨ৔ ߹͸MockΛݕ౼͢Δ

    15 Koichiro Oishi, 2017/10/02
  16. →Ͱ΋࣮ࡍʹ௨৴͢Δςετ͸ͨ·ʹ ࣦഊ͢Δ͜ͱ͕͋Δ • ඞͣ੒ޭ͢Δςετͱͨ·ʹࣦഊͯ͠͠·͏ςε τΛ෼ྨ →XcodeͳΒςετίʔυͷλʔήοτΛผʹ͢ ΔͳͲ • ྫ͑͹CIͰࣗಈςετ͢ΔͳΒࣦഊ͢Δςετ͸ 3ճ࿈ଓͨ͠Βࣦഊͱ൑ఆ͢ΔͳͲ

    16 Koichiro Oishi, 2017/10/02
  17. Viewͷςετ͸΍Βͳ͍ͱͩ ΊͰ͔͢ʁ 17 Koichiro Oishi, 2017/10/02

  18. →ViewͷςετΑΓ͸E2Eς ετΛ΍ͬͨํ͕ྑ͍ • View͸σβΠϯ΋ঢ়ଶ͕มΘΔ͔ΒɺView୯ମͷ ςετͱ͍͏ΑΓ͸εϞʔΫςετ΍E2Eςετ Λ΍ͬͨํ͕ྑ͍ → AppiumͳͲ • E2EςετΛߦ͏͜ͱͰਖ਼ৗܥͷςετ͸ࣗಈԽ

    Ͱ͖Δ → ྫ֎ܥͷෳࡶͳςετ͸ਓ͕ؒ΍Δඞཁ͕͋Δ 18 Koichiro Oishi, 2017/10/02
  19. ΧόϨοδʹ͍ͭͯ 19 Koichiro Oishi, 2017/10/02

  20. →໨ࢦ͢΂͖ΧόϨοδ • ·ͣ͸ϞσϧΛର৅ʹ80ʙ90%Λ໨ࢦͤ͹ྑ͍ →100%Λ໨ࢦ͢ͷ͸ͭΒΈ͕૿͢৔߹ͷ΋͋Δ ͷͰඞͣ͠΋໨ࢦ͞ͳͯ͘΋Α͍ 20 Koichiro Oishi, 2017/10/02

  21. →ࠓޙ΋ΧόϨοδΛҙࣝ͢ Δ͜ͱ • ΧόϨοδ͕ҡ࣋͞Ε͍ͯΔ → ಉ͡ൺ཰Ͱςετ͕ॻ͔Ε͍ͯΔ ! • ΧόϨοδ͕Լ͕͍ͬͯΔ →

    ςετ͕ॻ͔Ε͍ͯͳ͍ " 21 Koichiro Oishi, 2017/10/02
  22. XCTestͳΒXcode্Ͱ֬ೝͰ ͖·͢Ͷʂ 22 Koichiro Oishi, 2017/10/02

  23. ͝੩ௌ͋Γ͕ͱ͏ ͍͟͝·ͨ͠ 23 Koichiro Oishi, 2017/10/02