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

Closure Injectionでテストが書けた #hakata_test_night / ...

fromkk
December 14, 2018

Closure Injectionでテストが書けた #hakata_test_night / I could write test code with Closure Injection

HAKATA Test Night #1( https://testnight.connpass.com/event/102776/ )でClosure Injectionを利用する事でテストが書ける様になった事を発表してきました。

fromkk

December 14, 2018
Tweet

More Decks by fromkk

Other Decks in Programming

Transcript

  1. 1SPpMF struct Profile { let name = "Kazuya Ueoka" let

    twitter = "@fromkk" let github = "fromkk" let qiita = "fromkk" let company = "Timers Inc." } • !2
  2. େ·͔ͳྲྀΕ w ը૾ɾಈը͕୔ࢁ౉͞ΕΔ [PHAsset]  w 4΁ͷΞοϓϩʔυ༻ʹτʔΫϯΛ"1*͔Βऔಘ w ֤ϑΝΠϧຖʹϋογϡ஋Λੜ੒ w

    -PDBM%# $PSF%BUB ʹ*/4&35 ϋογϡ஋ͱ1)"TTFUMPDBM*EFOUJpFSΛඥ෇͚Δ  w 4ʹΞοϓϩʔυ͢ΔҝʹҰ୴ϑΝΠϧʹॻ͖ग़͠ AWSS3TransferUtility.uploadFileΛར༻͢ Δҝ  w ॻ͖ग़ͨ͠ϑΝΠϧΛ4ʹΞοϓϩʔυ w ঢ়ଶΛ%#ʹ61%"5& !5
  3. ϓϩμΫτίʔυ !13 var makeUrlTransfer: (UploaderToken) -> UploaderURLTransferProtocol = { (token)

    in return UploaderURLTransfer(token: token) } let error = UploaderError.uploadFailed uploader.makeUrlTransfer = { (token) in let urlTransfer = UploaderURLTransferStub(token: token) urlTransfer.result = false urlTransfer.error = error return urlTransfer } ςετίʔυ ίʔυͰදݱ͢Δͱ
  4. ·ͱΊ 1SPT w ֊૚ߏ଄ͷςετΛߟ͑ͨ࣌ʹ$MPTVSF*OKFDUJPOΛ࢖͑͹0CKFDUࣗମͷࠩ͠ସ͕͑Մೳ ʹͳͬͨͷͰςετ͕ग़དྷΔ༷ʹͳͬͨ w ϥΠϒϥϦͷར༻΍ผͷΫϥεΛ࡞Βͳͯ͘ࡁΜͩͷͰίεύ͸ྑ͍ؾ͕͢Δ# $POT w $MPTVSFͷҾ਺͕෼͔ΓͮΒ͘ͳΔ

    (Int, Int, Int, Int)ͱ͔શવ༗ΓಘΔ  w ύοͱݟṖͷϓϩύςΟ͕૿͑ΔͷͰείʔϓΛߜͬͨΓ͢Δ޻෉͸ඞཁͦ͏ w ෳ਺ճಉ͡Ϋϥε͕ੜ੒͞ΕΔ࣌ʹςετΛ͢Δͷ΋޻෉͕ඞཁ͔ͳͱࢥ͍·͢ !16
  5. !18

  6. !19