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
Golang API Testing the HARD way
Search
Seiji Takahashi
November 25, 2018
Programming
13
6.4k
Golang API Testing the HARD way
Presentations at GoConference 2018 Autumn.
Seiji Takahashi
November 25, 2018
Tweet
Share
More Decks by Seiji Takahashi
See All by Seiji Takahashi
Go Backends for frontends with GraphQL and gRPC
timakin
6
3.7k
Design Pattern for Image and Text Composition in Go
timakin
5
6.5k
Head First Golang Image Package
timakin
2
9.9k
React Native Beyond Prototype
timakin
2
1.6k
Performance Optimization on Google AppEngine
timakin
5
6.1k
testcache.pdf
timakin
1
120
How Go cache
timakin
1
62
How Go cache tests
timakin
1
2.9k
A/Bテスト機構がもたらす 大胆な開発体制及び ゆるやかなアプリ体験の変化 / Architecture and benefits of AB-test allocation system.
timakin
4
7.6k
Other Decks in Programming
See All in Programming
外部システム連携先が10を超えるシステムでのアーキテクチャ設計・実装事例
kiwasaki
1
170
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
4
2.8k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
610
[PyCon Korea 2024 Keynote] 커뮤니티와 파이썬, 그리고 우리
beomi
0
110
Going Staff - Keynote edition
pragtob
0
430
カラム追加で増えるActiveRecordのメモリサイズ イメージできますか?
asayamakk
3
1.1k
#pixiv小説画像メーカー はこうしてできた / The Making of the pixiv Novel Image Maker
roiban
0
220
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
4
150
watsonx.ai Dojo #3 プロンプトエンジニアリング入門
oniak3ibm
PRO
0
490
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
440
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
120
Vertical Architectures for Scalable Angular Applications
manfredsteyer
PRO
0
290
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
For a Future-Friendly Web
brad_frost
174
9.4k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Designing for humans not robots
tammielis
249
25k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
13
1.9k
A Philosophy of Restraint
colly
203
16k
Building Adaptive Systems
keathley
38
2.2k
Speed Design
sergeychernyshev
24
560
How to train your dragon (web standard)
notwaldorf
88
5.6k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Transcript
API TESTING THE HARD WAY @__timakin__ Go CONFERENCE 2018 Autumn
SEIJI TAKAHASHI timakin @__timakin__ __timakin__ ॴଐɿ(VOPTZ*ODϝσ ΟΞࣄۀຊ෦ ݴޠɿ(P 4XJGU +BWB4DSJQU
ΞδΣϯμ w (Pͷ"1*ͷςετʹ͓͚ΔςελϏϦςΟ w ςετʹؔ͢Δ5JQT w Ϣχοτςετʹ͍ͭͯ w ΠϯςάϨʔγϣϯςετʹ͍ͭͯ w
ϥΠϒϥϦબఆɺͭ·͍ͮͨՕॴ
None
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ w
5FTUJOHGSBNFXPSLT
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ w
5FTUJOHGSBNFXPSLT w OFUIUUQIUUQUFTUͷ͍ํ
ςετͷ࣮ྫ ʢಛʹΠϯςάϨʔγϣϯςετʣ ͷྫ͕Կނ͔ෆ͍ͯ͠Δʜ
(PͰςετ͢Δ߹ͷجຊ w JOUFSGBDFͷ׆༻ w AQBDLBHFYYY@UFTUAͱ͍͏໋໊ w 5BCMF%SJWFO5FTU w 5FTU$BDIF $PWFSBHF
#FODINBSL
*OUFSGBDFΛ׆༻ͯ͠ΔͱԿ͕͍͍ͷ͔ʁ w ผͷϨΠϠʔͷ࣮ΛΒͣʹίʔυΛॻ͖ਐΊΒ ΕΔ w ࣮ͷΓସ͕͑༰қʹߦ͑Δ w NPDLੜʹ͑Δ w αϯϓϧϨεϙϯεͷ࡞͕͍͠
֎෦"1*ݺͼग़͠ͳͲͰʹཱͭ
AQBDLBHFYYY@UFTUA w 5FTU1BDLBHFΛ࣮ͱ͢Δ w ࣮ࡍͷݺͼग़͠ํͱܗࣜΛ߹ΘͤΔ w QSJWBUFͳมʹର͢Δࢀর͕Ͱ͖ͳ͍Α͏ʹ͢Δ
5BCMF%SJWFO5FTU
5BCMF%SJWFO5FTU w ςετରͱͳΔσʔλྻɺ ظ͞ΕΔ݁ՌͷྻΛΠςϨʔτ͢Δ͜ͱͰ ෳͷςετέʔεΛ؆ܿʹ·ͱΊΒΕΔɻ w ϕϯνϚʔΫΛ͚ͨΓɺU1BSBMMFMΛ͍͍ͨ߹ 4VCUFTUTݕ౼͢Δɻ
5FTU$BDIF $PWFSBHF #FODINBSL w 5FTU$BDIF ςετؔ͝ͱʹ*%͕ৼΒΕͯɺ ݁Ռ͕ϑΝΠϧʹు͖ग़͞Εͯอଘ͞ΕΔɻ Ұக͢Δ݁Ռ͕͋Ε͍ճ͢ɻ w $PWFSBHF
#FODINBSL ඪ४Ͱαϙʔτ͞ΕΔ ΧόϨοδϨϙʔτͷग़ྗɺϕϯνϚʔΫ
$BDIFʹ͍ͭͯʜ IUUQTTQFBLFSEFDLDPNUJNBLJOIPXHPDBDIFUFTUT
(PͰςελϏϦςΟʔΛ্͛Δʹ w ͦͦςετ͕͠ʹ͍͘ίʔυμ ϝ w JOUFSGBDFͰϞοΫՄೳͳ෦ҐΛ૿͢ w ςετϔϧύʔͷॆ࣮ w ϢχοτςετʹدͤΒΕΔͱ͜Ζ
పఈͯ͠دͤΔׂͱେࣄ
(PͰςελϏϦςΟʔΛ্͛Δʹ w ϢχοτςετͷͨΊͷඪ४ػೳ͕ ॆ࣮͍ͯ͠ΔͷͰɺͦΕΛ׆༻͢ΔͨΊʹɺ Ͱ͖ΔݶΓߏମͷςετύοέʔδʹ ϩδοΫΛूதͤ͞Δɻ w 4FSWJDFʹϑΟϧλϦϯάͷϩδοΫΛͨ͠Γ ͠ͳ͍ɻ
͜͜·Ͱ͕લఏ
Ϣχοτςετͷ
Ϣχοτςετͷ5JQT w 5FTU)FMQFS w 4UVCTUBOEBSEQBDLBHFT w 'JYUVSFT w 5FTUJOHGSBNFXPSLT
5FTU)FMQFS U)FMQFS ΛݺͿ͜ͱͰɺ )FMQFSͷؔΛςετΛ ϚʔΫͯ͠ɺGBJMͨ࣌͠ʹ ݺͼग़͠ՕॴΛQSJOUͯ͘͠ΕΔɻ ͜ΕΛݺͳ͍ͱ෦ͰGBJM͠ ͨΓɺॲཧΛڞ௨Խͨ࣌͠ʹਏ ͍ࢥ͍Λ͢Δɻ
5FTU)FMQFS ඪ४ύοέʔδͷςετಛʹ)FMQFS͕׆༻͞Ε͍ͯΔ ʢSVO DPQZ'JMF OFX5FNQ%JSʣ
4UVCTUBOEBSEQBDLBHFT w UJNFύοέʔδɺSBOEύοέʔδͳͲͷ݁ՌΛ͏ ॲཧTUVC͢Δඞཁ͕͋Δ
ελϒํ๏ w άϩʔόϧมͷࠩ͠ସ͑ w ελϒՄೳͳϥούʔ w αʔυύʔςΟύοέʔδͷར༻
άϩʔόϧมͷࠩ͠ସ͑ άϩʔόϧͳมͰมΘΓ͏Δ݁ՌΛऔಘ͢ ΔΑ͏ʹ͠ɺςετ࣌ͦΕΛॻ͖͑Δɻ ಉ͡ͳΒͱ͔͘ɺQBSBMMFMͰͬͨ࣌ʹෆ ͕҆͋Δɻ HPSN͕ͬͯΔʜ IUUQTHJUIVCDPNKJO[IVHPSNCMPCNBTUFSVUJMTHP-
ελϒՄೳͳϥούʔ ελϒ༻ͷ͕ηοτ͞Εͯ ͍ͨΒఆతʹΛฦؔ͢Λ ఆٛ͢Δɻ
αʔυύʔςΟύοέʔδͷར༻ w ࣌ࠁݻఆ w HJUIVCDPNCFOCKPIOTPODMPDL w HJUIVCDPNULVDIJLJGBLFUJNF w DPEFDMPVEGPVOESZPSHDMPDL
4UVCTUBOEBSEQBDLBHFT w ʮ༗ޮظݶΛա͗ͨΒΤϯςΟςΟΛແޮԽ͢Δʯ Έ͍ͨͳॲཧ͕͋Δ߹ɺ࣌ࠁΛ୯७ʹݻఆ͢Δͩ ͚Ͱͳ͘ਐΊΔඞཁ͕͋Δ w ͦ͏ͨ͠߹αʔυύʔςΟͷύοέʔδߟ ྀʹೖΕΔ͕ɺʢ͍ͩͿ࣮͕গͳ͍ͷͰʣ جຊతʹؔͰϥοϓ͢ΕࣄΓΔͱࢥΘΕΔɻ
'JYUVSFT w ςετσʔλͷఆٛํ๏ w ߏମ w ྻͷσʔλߏʢ5BCMF%SJWFO5FTUʣ w ͦͷଞ w
+40/ :".-
'JYUVSFT w ߏମ w ϙΠϯλΛड͚औͬͯૢ࡞͢ΔؔΛςετ͢Δ ߹ɺςετ༻ͷมͷݩσʔλ͕มΘΓଓ͚ͯɺ ҙਤ͠ͳ͍ڍಈ͕ى͜Δɻ w 5BCMF%SJWFO5FTUͷΑ͏ʹݸผͷέʔεͰࢀর͢ Δσʔλ͕ҧ͏߹0,
'JYUVSFT w +40/ :".- w JPVUJM3FBE'JMFͯ͠ςετσʔλΛಡΈࠐΉ w ಡΈࠐΈ༻ͷσʔλJOQVU ·ͨTSD
ൺֱ༻ͷσʔλHPMEFO w "1*ͷϦΫΤετͱϨεϙϯεΛ શ෦+40/ఆ͓͍ٛͯͯ͠ςετ͢Δͷ͋Γ
'JYUVSFT w JOQVUHPMEFO w ඪ४ύοέʔδͰͷར༻Օॴ w ςετΧόϨοδϖʔδͷ༰ݕূ w (PEPDੜ༰ݕূ
'JYUVSFT w JOQVUHPMEFO w ඪ४ύοέʔδͰͷར༻Օॴ w ςετΧόϨοδϖʔδͷ༰ݕূ w (PEPDੜ༰ݕূ w
࣮ࡍͷར༻ྫ w "1*ͷϦΫΤετͱϨεϙϯεΛ શ෦+40/ఆ͓͍ٛͯͯ͠ςετ͢Δ w εςʔλείʔυ͚ͩνΣοΫ͢ΔΑ͏ͳ߹ɺ ϦΫΤετ͚ͩA TSDAͱ͍͏Α͏ͳ໋໊Ͱఆٛ͢Δͷ͋Γ
5FTUJOHGSBNFXPSLT w ʮ(Pͬͯɺ\\ҙͷݴޠ໊^^Ͱ͍͏ͱ͜Ζ\\ͦͷݴޠͷදత ͳςετϑϨʔϜϫʔΫ໊^^ͬͯͳΜ͔ͳ͍ΜͰ͔͢ʁʯ w "1*ϑϨʔϜϫʔΫͰಉ͕ٞ͋͡Δͱࢥ͍·͕͢ʜ
5FTUJOHGSBNFXPSLT w ʮ(Pͬͯɺ\\ҙͷݴޠ໊^^Ͱ͍͏ͱ͜Ζ\\ͦͷݴޠͷදత ͳςετϑϨʔϜϫʔΫ໊^^ͬͯͳΜ͔ͳ͍ΜͰ͔͢ʁʯ w "1*ϑϨʔϜϫʔΫͰಉ͕ٞ͋͡Δͱࢥ͍·͕͢ʜ w ςετϑϨʔϜϫʔΫͷੋඇ w ଞͷਓ͕ແݶʹޠ͍ͬͯΔͷͰলུ
w ʮͨͩͷ%4-ʯ w ʮίϯςΩετʹ͋ͬͨϝοηʔδදࣔʯ w ʮUFTUJOHͰඞཁेʯ w ʮϝϯςอূʯ w ʮπʔϧؒͷ࿈ܞͷऔΓ͢͞ʯ
5FTUJOHGSBNFXPSLT w ͜Ε͘Β͍ͳΒೖΕͯΑ͘ͳ͍ʁͱ͍͏ύοέʔδ w HJUIVCDPNHPPHMFHPDNQ w HJUIVCDPNTUSFUDISUFTUJGZ w 5BCMF%SJWFO5FTUͰͪΌΜͱςετέʔε໊ॻ͍͓͚ͯ ࠔΔ͜ͱগͳ͍ͷͰผʹ͍Βͳ͍͔
5FTUJOHGSBNFXPSLT w ͜Ε͘Β͍ͳΒೖΕͯΑ͘ͳ͍ʁͱ͍͏ύοέʔδ w HJUIVCDPNHPPHMFHPDNQ w HJUIVCDPNTUSFUDISUFTUJGZ w 5BCMF%SJWFO5FTUͰͪΌΜͱςετέʔε໊ॻ͍͓͚ͯ ࠔΔ͜ͱগͳ͍ͷͰผʹ͍Βͳ͍͔
w ݸਓతʹೖΕͳ͍ύοέʔδ w ඞཁेͳͣͷUFTUJOHύοέʔδͷϥούʔ w HPUFTUUPPMT w (P$POWFZ w (PCMJO
ΠϯςάϨʔγϣϯςετͷ
ΠϯςάϨʔγϣϯςετʹඞཁͳ͜ͱ w ࣮ߦڥ w %# DBDIF w 'JYUVSF w ࣌ࠁɾཚݻఆ
w DPOUFYUม w ֎෦"1*ͷ.PDL w "1*SFRSFTͷݕূ
࣮ߦڥͷߏங w %#ɺDBDIFΛͲͷΑ͏ʹཱͯΔ͔ w .PDL͢Δ w σʔϞϯ࣮ߦ w EPDLFSίϯςφΛཱͯΔ
%#पΓͰඞཁͳ࡞ۀ w ςετ࣮ߦ͝ͱʹҎԼͷϑϩʔΛ౿Ή ίωΫγϣϯཱ֬ ςʔϒϧ࡞ Ϛελσʔλద༻
ςετ࣮ߦ ςʔϒϧഁغ ίωΫγϣϯஅ
%#Λ.PDL͢Δͷྑ͍͔ʁ w ͋·ΓϕλʔͰͳ͍ͱࢥ͏ w 42-จ͕ؒҧ͍ͬͯΔ͔Ͳ͏͔ίϯύΠϧ࣌ʹ ؾ͚ͮͳ͍ w αʔυύʔςΟ"1*ͳΒ·ͩ͠ɺ%#ͳΒࣗͰ ڥ͕༻ҙͯ͠ɺҙਤ௨Γ͔Ͳ͏͔ͷݕূ͕ Ͱ͖Δͷ͔ͩΒɺ.PDL͠ͳ͍ํ͕ྑ͍
σʔϞϯ࣮ߦ w HJUIVCDPNMFTUSSBUHPUFTUNZTRME w Կߟ͑ͳͯ͘NZTRME͕࣮ߦͰ͖Δ
ίϯςφ w (PͰ%PDLFSʹଓ͢Δϥούʔ w HJUIVCDPNGTPV[BHPEPDLFSDMJFOU w HJUIVCDPNPSZEPDLFSUFTU w ςετͷͨΊʹ.Z42-3FEJTଓ͕Ͱ͖Δ ྗڧ͍ϥούʔ
w ࣗલͰEPDLFSίϯςφͨͯΔ࣌ʹඞཁͳ ىಈ֬ೝऔΕΔ·Ͱͷ1JOHͳͲΛͬͯ͘ΕΔ
ίϯςφ
γϯϓϧͳଓ %#ͷίωΫγϣϯͳͲɺ DMPTFͷॲཧ͕ඞཁͳ ͷɺ UFBSEPXO༻ͷGVODΛฦ ٫͓͍ͯͯ͠ɺ ࢀর͍ͯ͠ΔؔͰ EFGFSͰ࣮ߦ͢Δͱ ҆શɻ
'JYUVSF w ϢχοτςετͱҟͳΓ༻్͕͍͔ͭ͋͘Δ w SFRSFTݕূ༻ͷQBZMPBE w ࣄલʹ%#ʹೖΕ͓ͯͨ͘Ίͷσʔλ w ڞ௨ͷϚελσʔλ w
ݸผͷςετ༻ʹ༻ҙ͞Εͨσʔλ
SFRSFTݕূ༻ͷQBZMPBE w JOQVUHPMEFOͰQBZMPBEΛ+40/ʹ·ͱΊ͓ͯ͘ w ΫΤϦύϥϝʔλʔඞཁͳΒΓग़͓ͯ͘͠
ςʔϒϧ࡞ɾআ w ςʔϒϧఆ͕ٛΒͭ͘ͱ໘ͳͷͰɺ HJUIVCDPNLLVCVOTRMEFGΛͬͯ ҰݸͷεΩʔϚʹ࠷৽ͷঢ়ଶΛ·ͱΊ͓ͯ͘ͱศར
ςʔϒϧ࡞ɾআ
None
Ϛελσʔλςετ͝ͱͷσʔλ w ݸਓతʹҎԼͷΑ͏ʹɺϚελσʔλͱͦΕҎ֎ Λ͚͍ͯΔ w UFTUEBUBpYUVSFTEFGBVMU w Ϛελσʔλ w UFTUEBUBpYUVSFTPQUJPOBM
w ςετέʔεʹΑͬͯࢀরͨ͠Γ͠ͳ͔ͬͨΓ͢ Δσʔλ
σʔλ࡞
σʔλ࡞
ಛघͳσʔλૠೖ w .Z42- 1PTHSF42-ͳͲͷσʔλૠೖָ w ("&ΛͬͯΔͱ%BUBTUPSFʹ 'JYUVSFΛೖΕͨ͘ͳΔ
None
ETNPDL w 'JYUVSFͷ:".-ఆٛΛࢦఆ͢Εɺࢦఆͷ,JOEͷ σʔλΛྲྀ͠ࠐΊΔ w $MFBOVQ࡞ۀผ్ඞཁ
࣌ࠁɾཚݻఆ w ௨ৗͷςετͱಉ༷ɻϞοΫ༻ͷؔΛఆٛͯ͠ɺ Ϧηοτ༻ͷؔΛSFUVSOͯ͠ྑ͍ɻ
$POUFYUม w DPOUFYU෦ͷΛͬͯॲཧ͢Δ߹ɺUFTU༻ͷDPOUFYUʹ ΛೖΕ͓ͯ͘ඞཁ͕͋Δ w ଟօ͞Μ͕෦Ͱఆ͍ٛͯ͠Δ/FX$POUFYU8JUI999ͳϝ ιουΛݺͿͷྑ͍͕ɺͪΌΜͱϦΫΤετͱͯ͠ ݕূ͢ΔͳΒͤΊͯSFRʹΛૠೖ͓͖͍ͯͨ͠ɻ
֎෦"1*ͷ.PDL w ֎෦"1*͏Ͳ͏͠Α͏ͳ͍ͷͰ.PDL͢Δ w NPDLೖΕͯΔͷʹͬͯͳ͍ͱΤϥʔͰऴྃ͢Δ ͷͰɺNPDL͚ͩॲཧΛڞ௨Խͤͣ ɺݸผͷςε τέʔεͰૠೖ͢Δɻ
.PDLͷίϯτϩʔϥʔੜ
.PDLར༻
"1*SFRSFTͷݕূ w HPMBOHHPBQQFOHJOFͷެࣜύοέʔδʹʑ AUSZAͱ͍͏ϥούʔ͕͋Δɻ w ϦΫΤετݕূςετͷग़ྗ݁ՌͳͲͷݕূ AUSZAͱ͍͏ஆ͔͍͕ؔͬͯ͘Εͯͯɺ ඇৗʹ࣮ͷࢀߟʹͳΔ
SFRSFTΛݕূ͢Δ߹ʜ
None
None
؆ૉ☺
͓·͚
5FTU3VOOFSࣗମͷϥούʔ w ΠϯςάϨʔγϣϯςετͰΔ͜ͱ ͍͍ܾͩͨ·ͬͯΔ w UFTUJOH.Λड͚औΔؔͰϥοϓͯ͋͛͠Δͱ εοΩϦ͢Δ
None
·ͱΊ w ۃྗ"1*ͷςετϢχοτςετͰϩδοΫΛ୲อͰ͖ΔΑ ͏ʹɺ࣮Λߏମۙ͘ʹدͤΔ w ΠϯςάϨʔγϣϯςετͷϊϋ·ͩ·ͩΦʔϓϯ͡Ό ͳ͍͚Ͳɺެࣜύοέʔδͷஆ͔͍ςετ͕ඇৗʹࢀߟʹͳΔ w γϯϓϧ͞ΛอͪͭͭɺͲ͜·Ͱڞ௨ԽͰ͖Δ͔͕ޣຯͳͷ ͰɺͦΕΛָ͠Έ·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ