Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in S...
Search
Jiro Nagashima
February 28, 2015
Technology
4
9.2k
SwiftでHTTP通信のスタブ化 / Stubbing HTTP Requests in Swift
#33testing
Jiro Nagashima
February 28, 2015
Tweet
Share
More Decks by Jiro Nagashima
See All by Jiro Nagashima
グロースを加速するLooker活用 / Leveraging Looker to accelerate growth
hedjirog
3
2.8k
プロダクトの成長を支えるKPI / KPIs for growing your product
hedjirog
17
3.8k
UIViewPropertyAnimatorで実現するリッチなアニメーション表現
hedjirog
4
2.3k
ReactorKit at Wantedly
hedjirog
2
970
ReactorKitを利用した緩やかなアーキテクチャの移行
hedjirog
3
1.5k
限られたリソースで進める段階的なSwit移行
hedjirog
2
5.2k
エンジニア・デザイナーで取り組むグロースハック
hedjirog
6
2.3k
iOS 10 時代のアニメーション / Introduction to UIViewPropertyAnimator
hedjirog
3
3k
How we use fastlane at Wantedly
hedjirog
9
11k
Other Decks in Technology
See All in Technology
不安定だったテストが信頼を取り戻すまで / The Road to Trustworthy Tests
katawara
0
120
Java 30周年記念! Javaの30年をふりかえる
skrb
4
2.5k
CSSDay, Amsterdam
brucel
0
250
Eight Engineering Unit 紹介資料
sansan33
PRO
0
3.3k
Web Intelligence and Visual Media Analytics
weblyzard
PRO
1
6k
ソフトウェアテストのAI活用_ver1.10
fumisuke
0
260
LT:組込み屋さんのオシロが壊れた!
windy_pon
0
570
障害を回避するHttpClient再入門 / Avoiding Failures HttpClient Reintroduction
uskey512
1
390
NW運用の工夫と発明
recuraki
2
850
Introduction to Bill One Development Engineer
sansan33
PRO
0
240
為什麼我們需要 Observability?
marcustung
0
440
ソフトウェアは捨てやすく作ろう/Let's make software easy to discard
sanogemaru
10
6.2k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
15
900
GraphQLとの向き合い方2022年版
quramy
46
14k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
106
19k
We Have a Design System, Now What?
morganepeng
52
7.6k
Building Applications with DynamoDB
mza
95
6.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
How to Think Like a Performance Engineer
csswizardry
24
1.6k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Code Reviewing Like a Champion
maltzj
524
40k
The Pragmatic Product Professional
lauravandoore
35
6.7k
How to Ace a Technical Interview
jacobian
276
23k
Fireside Chat
paigeccino
37
3.5k
Transcript
4XJGU Ͱ )551௨৴ͷελϒԽ !IFEKJSPH
ͳ͕͠·͡Ζ͏ !IFEKJSPH 4BOTBOגࣜձࣾ&JHIU
)551௨৴ͷελϒԽ
/-5)5514UVC4FSWFS ैདྷख๏ 0))5514UVCT FUD…
ΞϓϦ෦ͷαʔόʔ ैདྷख๏ /463-1SPUPDPMʹ४ڌͨ͠Ϋϥε .FUIPE4XJ[[MJOH
ʷΞϓϦ෦ͷαʔόʔ ैདྷख๏ ʷ/463-1SPUPDPMʹ४ڌͨ͠Ϋϥε ʷ.FUIPE4XJ[[MJOH
.PZB
None
None
.PZB w ωοτϫʔΫपΓͷநԽϨΠϠʔ w ςετ༻ͷελϒѻ͑Δ
Πϝʔδ͜Μͳײ͡ IUUQEFWFMPQFSIBUFOBTUBGGDPNFOUSZTNBSUBQJDMJFOUXJUITXJGU VTJOHFOVNBOEHFOFSJDT
IFEKJSPH2JJUB'FFE
"1*ͷهड़
enum QiitaAPI { case Items case TagItems(String) } FOVNఆٛ
extension QiitaAPI : MoyaPath { var path: String { switch
self { case .Items: return "/api/v2/items" case .TagItems(let tagID): return "/api/v2/tags/\(tagID)/items" } } } ύεࢦఆ
extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return
NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } B63-ࢦఆ
extension QiitaAPI : MoyaTarget { var baseURL: NSURL { return
NSURL(string: "https://qiita.com")! } var sampleData: NSData { switch self { case .Items, .TagItems: return stubbedResponse("Items") } } } CελϒԽͨ͠ϨεϙϯεΛࢦఆ
ϓϩόΠμͷΓସ͑
static func DefaultProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure) }
static func StubbingProvider() -> ReactiveMoyaProvider<QiitaAPI> { return ReactiveMoyaProvider(endpointsClosure: endpointsClosure, stubResponses: true) } ϓϩόΠμఆٛ
QiitaProvider.sharedProvider = QiitaProvider.StubbingProvider() Γସ͑
IUUQTHJUIVCDPNBSUTZFJEPMPO ࢀߟ IUUQTHJUIVCDPN"TI'VSSPX.PZB σϞ IUUQTHJUIVCDPNIFEKJSPH2JJUB'FFE