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

Page Object Pattern with XCUITest

Page Object Pattern with XCUITest

potatotips #59での発表。XCUITestを使ったPage Object Patternを紹介。
内容は記事にもまとめていますので、こちらもどうぞ。
https://www.wantedly.com/companies/wantedly/post_articles/155005

Kento Nagata

February 28, 2019
Tweet

More Decks by Kento Nagata

Other Decks in Programming

Transcript

  1. ©2018 Wantedly, Inc.
    Page Object Pattern
    with XCUITest
    potatotips #59 2019/02/28
    Kento Nagata, Wantedly, Inc.

    View full-size slide

  2. ©2018 Wantedly, Inc.
    ,FOUP/BHBUB
    8BOUFEMZ *OD4PGUXBSF&OHJOFFS
    8IBU*EPOPX
    ɾ(SPXUIPG8BOUFEMZ7JTJU

    &OHJOFFSJOH
    ɾ3BJMTZFBST
    ɾJ044XJGUZFBS/FX

    View full-size slide

  3. ©2018 Wantedly, Inc.
    6*౷߹ςετΛ΋ͬͱྑ͘͢Δ

    1BHF0CKFDU1BUUFSO
    ࠓ೔࿩͢͜ͱ

    View full-size slide

  4. ©2018 Wantedly, Inc.
    9$6*5FTUͰ6*ͷ౷߹ςετΛॻ͖͍ͨ
    લఏ

    View full-size slide

  5. ©2018 Wantedly, Inc.
    1BHF0CKFDU1BUUFSO͸ɺ

    ςετର৅Ͱ͋ΔϖʔδΛந৅Խͯ͠ɺ

    %3:͔ͭ3FBEBCMFͳ

    ςετίʔυΛ࣮ݱ͠·͢ɻ

    View full-size slide

  6. ©2018 Wantedly, Inc.
    ॏෳͨ͠ίʔυ
    ҙਤͷಡΈͮΒ͍ίʔυ
    Page Object Pattern ͕ղܾ͢Δ՝୊

    View full-size slide

  7. ©2018 Wantedly, Inc.
    ৽نొ࿥ϑϩʔͷྫ

    View full-size slide

  8. ©2018 Wantedly, Inc.
    8FMDPNF1BHF
    ىಈ௚ޙͷ࠷ॳͷϖʔδ
    ɾΠϯετʔϧޙʹॳΊͯىಈͨ͠ޙ
    ɾ৽نొ࿥͔ϩάΠϯΛબ୒Ͱ͖Δ
    ɾࠓճ͸4JOH6QϘλϯΛԡ͢
    ৽نొ࿥ϑϩʔͷྫ

    View full-size slide

  9. ©2018 Wantedly, Inc.
    4JHOVQ1BHF
    ৽نొ࿥ϖʔδ
    ɾ&NBJMɺύεϫʔυɺ໊લΛೖྗͰ͖Δ
    ɾશͯೖྗ͢Δͱ4JHOVQϘλϯ͕ԡͤΔ
    ৽نొ࿥ϑϩʔͷྫ

    View full-size slide

  10. ©2018 Wantedly, Inc.
    4JHOVQ1BHF
    ৽نొ࿥ϖʔδ
    ɾ&NBJMɺύεϫʔυɺ໊લΛೖྗͰ͖Δ
    ɾશͯೖྗ͢Δͱ4JHOVQϘλϯ͕ԡͤΔ
    ৽نొ࿥ϑϩʔͷྫ

    View full-size slide

  11. ©2018 Wantedly, Inc.
    $PNQMFUF1BHF
    ׬ྃϖʔδ
    ɾొ࿥͕׬ྃͨ͜͠ͱΛ఻͑Δ
    ɾ4UBSUϘλϯΛԡ͢ͱ࢖͍࢝ΊΒΕΔ
    ৽نొ࿥ϑϩʔͷྫ

    View full-size slide

  12. ©2018 Wantedly, Inc.
    Welcome Page Sign up Page Complete Page

    View full-size slide

  13. ©2018 Wantedly, Inc.
    ςετίʔυ
    9$6*5FTUͰͦͷ··ॻ͍ͯΈΔ

    View full-size slide

  14. ©2018 Wantedly, Inc.

    View full-size slide

  15. ©2018 Wantedly, Inc.

    View full-size slide

  16. ©2018 Wantedly, Inc.

    View full-size slide

  17. ©2018 Wantedly, Inc.

    View full-size slide

  18. ©2018 Wantedly, Inc.

    View full-size slide

  19. ©2018 Wantedly, Inc.

    View full-size slide

  20. ©2018 Wantedly, Inc.

    View full-size slide

  21. ©2018 Wantedly, Inc.

    View full-size slide

  22. ©2018 Wantedly, Inc.
    ॏෳͨ͠ίʔυ
    w Ϣʔβ΍؀ڥʹͳͲͷ৚݅ʹΑͬͯ෦෼తͳ෼ذͳͲ͕͋Δ৔߹ɺ༷ʑͳέʔεͰςετ͍ͨ͠
    w ͋Γ͕ͪͳΞϓϩʔν͸ɺίϐϖɺϝιου੾Γग़͠
    w ίϐϖ͸ɺ%3:Ͱͳ͘มԽʹऑ͍
    w ϝιου੾Γग़͠͸ɺந৅Խͷཻ౓͕ἧΘͣಡΈͮΒ͍
    ҙਤͷಡΈͮΒ͍ίʔυ
    w 8IBUΛίϝϯτͨ͘͠ͳΔͷ͸ɺѱ͍αΠϯ
    w ຊདྷͷ੹຿͸ɺҰ࿈ͷૢ࡞ͷྲྀΕͱΞαʔγϣϯ͚ͩ
    Կ͕໰୊͔

    View full-size slide

  23. ©2018 Wantedly, Inc.
    ͦ͜Ͱɺ1BHF0CKFDU1BUUFSO

    View full-size slide

  24. ©2018 Wantedly, Inc.

    View full-size slide

  25. ©2018 Wantedly, Inc.
    WelcomePage
    class

    View full-size slide

  26. ©2018 Wantedly, Inc.
    WelcomePage
    class
    SignUpPage
    class

    View full-size slide

  27. ©2018 Wantedly, Inc.
    WelcomePage
    class
    SignUpPage
    class
    CompletePage
    class

    View full-size slide

  28. ©2018 Wantedly, Inc.
    WelcomePage
    class
    SignUpPage
    class
    CompletePage
    class
    func tapSignUpButton()
    func tapLoginButton()
    var errorMessage: String
    func typeEmail(_:)
    func typePassword(_:)
    func typeName(_:)
    func tapSignUpButton()
    var userName: String
    func tapStartButton()

    View full-size slide

  29. ©2018 Wantedly, Inc.
    WelcomePage
    class
    SignUpPage
    class
    CompletePage
    class
    func tapSignUpButton()
    func tapLoginButton()
    var errorMessage: String
    func typeEmail(_:)
    func typePassword(_:)
    func typeName(_:)
    func tapSignUpButton()
    var userName: String
    func tapStartButton()
    ݱࡏͷঢ়ଶΛฦ͢ϓϩύςΟ

    View full-size slide

  30. ©2018 Wantedly, Inc.
    WelcomePage
    class
    SignUpPage
    class
    CompletePage
    class
    func tapSignUpButton()
    func tapLoginButton()
    var errorMessage: String
    func typeEmail(_:)
    func typePassword(_:)
    func typeName(_:)
    func tapSignUpButton()
    var userName: String
    func tapStartButton()
    ͦͷϖʔδ΁ͷૢ࡞ͷϝιου

    View full-size slide

  31. ©2018 Wantedly, Inc.
    ॳظԽ࣌ʹͦͷϖʔδͷଘࡏΛΞαʔγϣϯ
    ૢ࡞ͷϝιου͸࣮ߦޙͷ1BHFΦϒδΣΫτΛ

    ฦ͢
    • ϝιουνΣʔϯ͕Ͱ͖Δ
    • ը໘ભҠ͕ൃੜ͠ͳ͍৔߹͸selfΛฦ͢
    Page Object Pattern ͷϙΠϯτ

    View full-size slide

  32. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  33. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  34. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  35. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  36. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  37. ©2018 Wantedly, Inc.
    Page Object Patter Λ࢖ͬͨςετίʔυ

    View full-size slide

  38. ©2018 Wantedly, Inc.
    ಡΈ΍͘͢ͳͬͨʂ

    View full-size slide

  39. ©2018 Wantedly, Inc.
    ۩ମతͳ࣮૷
    1BHF1SPUPDPMͱͦͷ۩ମ࣮૷ͷ঺հ

    View full-size slide

  40. ©2018 Wantedly, Inc.
    1BHF1SPUPDPM
    ϓϩτίϧΛ࡞Ζ͏
    ࠷௿ݶͷΠϯλʔϑΣΠεΛἧ͑ΔͨΊʹ1SPUPDPM
    Λ࡞Γ·͢ɻ
    ɾBQQଞͷ1BHFΛ࡞ΔͨΊʹอ࣋͠·͢
    ɾWJFXϖʔδΛද͢਌ཁૉ 7JFX$POUSPMMFSͷWJFX
    ʹͳΔ͜ͱ͕ଟ͍

    ɾJOJU BQQΛड͚औͬͯηοτ͢Δ͜ͱΛظ଴͠·
    ͢
    1BHF1SPUPDPM
    ۩ମతͳ࣮૷

    View full-size slide

  41. ©2018 Wantedly, Inc.

    View full-size slide

  42. ©2018 Wantedly, Inc.
    Page Protocolʹ४ڌ

    View full-size slide

  43. ©2018 Wantedly, Inc.
    Page Protocolʹ४ڌ

    View full-size slide

  44. ©2018 Wantedly, Inc.
    ϖʔδ্ͷΤϥʔϝοηʔδΛද͢ϓϩύςΟ

    View full-size slide

  45. ©2018 Wantedly, Inc.
    ૢ࡞ʹඞཁͳཁૉΛ༻ҙ

    View full-size slide

  46. ©2018 Wantedly, Inc.
    ֤ૢ࡞ͷϝιουΛఆٛɺૢ࡞ޙͷϖʔδΛฦ͢

    View full-size slide

  47. ©2018 Wantedly, Inc.
    ૢ࡞ʹඞཁͳཁૉ΋1SJWBUFQSPQFSUZͰఆٛ
    w ֤ૢ࡞ϝιουͷఆٛ΋γϯϓϧʹͳΔ
    Ξαʔγϣϯʹඞཁͳϖʔδͷঢ়ଶ͸

    $PNQVUFEQSPQFUZͱͯ͠ఆٛ
    w ඞཁ࠷௿ݶͷཁૉ͚ͩΛฦ͢
    w ෳࡶʹͳΔͳΒઐ༻ͷ4USVDUΛఆٛ͢Δͷ΋͋Γ
    Page ͷ࣮૷ͷϙΠϯτ

    View full-size slide

  48. ©2018 Wantedly, Inc.
    ·ͱΊ

    View full-size slide

  49. ©2018 Wantedly, Inc.
    w 1BHF0CKFDU1BUUFSO͸%3:͔ͭ3FBEBCMFͳ

    6*ςετΛ࣮ݱͰ͖Δ
    w ͜ͷύλʔϯ͸"OESPJE΍8FCͰ΋࢖͑Δ
    w ͲΜͲΜ׆༻͍ͯ͜͠͏
    ·ͱΊ

    View full-size slide