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.2k
ReactorKit at Wantedly
hedjirog
2
960
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
Next.jsと状態管理のプラクティス
uhyo
6
2.4k
猫でもわかるS3 Tables【Apache Iceberg編】
kentapapa
2
260
Why Platform Engineering? - マルチプロダクト・少人数 SRE の壁を越える挑戦 -
nulabinc
PRO
5
480
Design for Failure - リージョンとAZについて
yuki_ink
0
130
GPU 클라우드 환경에서의 회복탄력적 AI 운영 : 훈련 및 추론을 위한 견고한 아키텍처와 전략
inureyes
PRO
0
130
MagicPodが描くAIエージェント戦略とソフトウェアテストの未来
magicpod
0
290
4月15日の AZ 障害をテクサポの中の人目線で振り返ってみる
kazzpapa3
3
180
ITベンダーから見る内製化支援の本質/in-house-dev
slsops
1
160
技術選定を突き詰める 懇親会LT
okaru
2
1.2k
kernelvm-brain-net
raspython3
0
660
Kaigi Effect 2025 #rubykaigi2025_after
sue445
0
200
The PyArrow revolution in Pandas
reuven
0
120
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
512
110k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
122
52k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
34
2.2k
It's Worth the Effort
3n
184
28k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
850
The Language of Interfaces
destraynor
158
25k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Faster Mobile Websites
deanohume
307
31k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
19
1.2k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
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