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

プロジェクトの1ファイルに単体テストを書いてみた!〜本当にこれで合ってるの…??🤔〜

takattata
December 05, 2017

 プロジェクトの1ファイルに単体テストを書いてみた!〜本当にこれで合ってるの…??🤔〜

iOS Test Night #6にて発表した時の資料です!

takattata

December 05, 2017
Tweet

More Decks by takattata

Other Decks in Programming

Transcript

  1. 1
    2017.12.05 @iOS Test Night
    ੒௕Մೳੑʹ
    ϓϩδΣΫτͷ1ϑΝΠϧʹ୯ମςετΛॻ͍ͯΈͨʂ
    ʙຊ౰ʹ͜ΕͰ߹ͬͯΔͷ…??ʙ
    @takattata

    View Slide

  2. 2
    To do
    ΍Γ͍ͨ͜ͱ

    View Slide

  3. 3
    ままのて
    ΍Γ͍ͨ͜ͱ

    View Slide

  4. 4
    ままのて
    ΍Γ͍ͨ͜ͱ
    ɾΫϦʔϯΞʔΩςΫνϟ
    ɾ4XJGU
    ɾ9DPEF
    ɾ$PDPB1PET
    ɾ#JUSJTF
    ˠ9$5FTUͰ͜ͷϓϩδΣΫτͷςετΛॻ͖͍ͨ

    View Slide

  5. 5
    ʮ·ͣ%BUB4UPSFͷςετΛॻ͍ͯΈΑ͏ʯ
    ͱ͍͏༁Ͱ'BWPSJUF%BUB4UPSFΫϥεΛબ୒ ˣ͜Μͳײ͡ͷಈ͖

    ΍Γ͍ͨ͜ͱ
    Ϋϥε಺ͷؔ਺
    ɾFYJTUT ࠨ͕࣮෺

    ɾHFU"MM
    ɾDSFBUF

    ɾEFMFUF

    View Slide

  6. 6
    ͓खݩʹTwitterͷ४උΛ͓ئ͍͠·͢!!
    ࠓճͲ͏ઃఆ͠ɺॻ͍͔ͨΛ࿩ͤͯ͞௖͖·͕͢ɺ

    ʮ΢ν΋ͦ͏ͯ͠ΔΑʔʯʮ͜͏͡Όͳ͍ʁʯͳͲɺ

    ੋඇ!ͲΜͲΜ!ᄁ͍͍ͯͩ͘͞!!(ޙ௥͍͢ΔͷͰ!)
    #ios_test_night ෇͚ͯੋඇ!͓ئ͍͠·͢!!
    ɹ͓ئ͍!!ɹ

    View Slide

  7. 7
    ࿩ͷྲྀΕ
    ɾॻ͍ͨςετͷߏ੒
    ɾ3Y4XJGUͷςετͷॻ͖ํ
    ɾ$PDPB1PETͷઃఆ
    ɾϓϩδΣΫτͷઃఆ
    ɾ#JUSJTFͷઃఆ

    View Slide

  8. 8
    Structure
    ॻ͍ͨςετͷߏ੒
    ࣭໰

    View Slide

  9. 9
    ςετͷߏ੒
    ॻ͍ͨςετͷߏ੒
    'BWPSJUF%BUB4UPSF5FTUTΫϥε
    'BWPSJUF%BUB4UPSFΫϥεΛϝϯόม਺ʹ࣋ͪɺඇಉظςετ͢Δ
    ςετର৅ɿ'BWPSJUF%BUB4UPSFΫϥε
    'JSFCBTFʹΞΫηεͯ͠σʔλͷ΍ΓऔΓΛ͢Δ
    ˠ͜ͷ෦෼ΛϞοΫʹࠩ͠ସ͑Δ
    'BWPSJUF%BUB4UPSF.PDLΫϥε
    'JSFCBTFͷ୅ΘΓʹ഑ྻʹอ࣋ͯ͠΍ΓऔΓΛ͢Δ

    View Slide

  10. 10
    ɾςετର৅ͷFavoriteDataStoreΛϝϯόม਺Ͱ͍࣋ͨͤͯΔ
    @FavoriteDataStoreTestsΫϥε
    ॻ͍ͨςετͷߏ੒ ※Ҏ߱ɺίʔυͰ”Dao”ͱॻ͔Ε͍ͯ·͕͢ɺDataStoreʹ೴಺ஔ׵Λ͓ئ͍͠·͢ɻ

    View Slide

  11. 11
    ॻ͍ͨςετͷߏ੒
    @FavoriteDataStoreMockΫϥε

    View Slide

  12. 12
    @FavoriteDataStoreΫϥε
    Q1. ςετͷ࣌ͷͨΊʹΘ͟Θ͟ϞοΫΛϝϯόม਺ʹ࣋ͭ΋ͷʁ

    Q2. ςετͷ࣌͸ͪ͜ΒΛ௨ΔΑ͏ʹifจͰ෼ذ͔͠ํ๏ͳ͍ͷʁ
    ॻ͍ͨςετͷߏ੒

    View Slide

  13. 13
    Using RxSwift
    RxSwiftͷςετͷॻ͖ํ
    ࣭໰

    View Slide

  14. 14
    3Y4XJGUͷςετͷॻ͖ํ
    @FavoriteDataStoreTestsΫϥε
    Q3. create͞Ε͔ͯΒexistsΛ࠶֬ೝ͠Α͏ͱ͍ͯ͠·͢ɻ

    ڍಈͱͯ͠͸ҙਤͨ͠΋ͷʹͳ͍ͬͯ·͕͢ɺ

    ॻ͖ํ߹ͬͯ·͔͢???

    View Slide

  15. 15
    Setting CocoaPods
    CocoaPodsͷઃఆ
    ࣭໰

    View Slide

  16. 16
    $PDPB1PETͷઃఆ
    @Podfile

    Q4. :search_pathsʹ͢Δͱɺ͜͜ʹ΋pod ‘Firebase’Λ͠ͳ͍ͱౖΒΕ
    Δ…ɻ1จͰઆ໌͞ΕͯΔͷ͔͠ݟ౰ͨΒͣɺҧ͍ͷৄࡉ͕஌Γ͍ͨͰ͢ɻ

    Q5. ೖΕࢠʹͨ͠Βग़དྷ্͕Δtestλʔήοτͷ.framework໊͕Pods_ϓ
    ϩδΣΫτ໊_ϓϩδΣΫτ໊TestsʹมΘΓ·ͤΜʁආ͚ํ͋Γ·͢ʁ

    Q6. ೖΕࢠʹͤͣʹɺdef common_pods … endͷΑ͏ʹͯͦ͠ΕͧΕͷ
    targetͰݺΜͰΔਓ΋͍·͕ͨ͠ɺօ͞ΜͲ͏͞Εͯ·͢ʁ
    ※Q5ͷΑ͏ʹframework໊͕มΘΔ͜ͱʹΑΓɺFrameworksͷࢀর͔Β

    ݩͷ໊લͷ.frameworkΛ࡟আ͢Δඞཁ͕͋Γ·ͨ͠ɻ

    View Slide

  17. 17
    Setting project
    ϓϩδΣΫτͷઃఆ
    ࣭໰

    View Slide

  18. 18
    ϓϩδΣΫτͷઃఆ
    Edit Scheme… > Test > InfoλϒΑΓ

    View Slide

  19. 19
    ϓϩδΣΫτͷઃఆ
    TARGETS: ϓϩδΣΫτ໊Tests > Build Settings
    > pod install͢ΔͱˣͷΑ͏ʹౖΒΕΔͷͰɺ
    Yes ͔Β $(inherited) ʹมߋ

    View Slide

  20. 20
    Setting Bitrise
    Bitriseͷઃఆ
    ࣭໰

    View Slide

  21. 21
    ϓϩδΣΫτͷઃఆ
    Workflow > StagingͷΈ
    ڬΜ͚ͩͩ

    View Slide

  22. 22
    ʮ·ͣDataStoreͷςετΛॻ͍ͯΈΑ͏ʯ
    ଘ෼ʹᄁ͍ͯ௖͚ͨͰ͠ΐ͏͔?

    ͝ڠྗ͋Γ͕ͱ͏͍͟͝·ͨ͠!!

    ࠙਌ձͰ΋ੋඇ৭ʑ͓࿩ฉ͔͍ͤͯͩ͘͞!!

    ಛʹ”RxTest”ͷ࢖͍ॴͱ͔!!
    MISSION:

    COMPLETE

    View Slide