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 Swift
Search
Jiro Nagashima
February 28, 2015
Technology
4
9k
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.4k
プロダクトの成長を支えるKPI / KPIs for growing your product
hedjirog
17
3.6k
UIViewPropertyAnimatorで実現するリッチなアニメーション表現
hedjirog
4
1.9k
ReactorKit at Wantedly
hedjirog
2
800
ReactorKitを利用した緩やかなアーキテクチャの移行
hedjirog
3
1.3k
限られたリソースで進める段階的なSwit移行
hedjirog
2
4.9k
エンジニア・デザイナーで取り組むグロースハック
hedjirog
6
2.2k
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
On Your Data を超えていく!
hirotomotaguchi
2
690
Cracking the KubeCon CfP
inductor
2
250
アクセシビリティを考慮したUI/CSSフレームワーク・ライブラリ選定
yajihum
2
1k
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
1
250
Cypress or Playwright?
rainerhahnekamp
0
110
非同期推論システムによるコスト削減と信頼性向上
koki_nishihara
0
260
元インフラエンジニアに成る / Human Resources to Human Relations
bobtani
4
930
いつか使うかも貯金してたらめちゃめちゃ機能が増えてた話
riyaamemiya
0
330
EMとして2023年度に頑張ったこと / What we did well in FY2023 as a EM
pauli
1
170
web-application-security
matsuihidetoshi
0
170
プロトタイピングによる不確実性の低減 / Reducing Uncertainty through Prototyping
ohbarye
5
390
Terraformあれやこれ/terraform-this-and-that
emiki
8
1.4k
Featured
See All Featured
Code Review Best Practice
trishagee
55
15k
The Power of CSS Pseudo Elements
geoffreycrofte
60
5k
RailsConf 2023
tenderlove
4
540
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
A designer walks into a library…
pauljervisheath
200
23k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Into the Great Unknown - MozCon
thekraken
10
990
A better future with KSS
kneath
231
16k
Build your cross-platform service in a week with App Engine
jlugia
225
17k
Designing Experiences People Love
moore
136
23k
GraphQLとの向き合い方2022年版
quramy
32
12k
Optimising Largest Contentful Paint
csswizardry
8
2.4k
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