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
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
410
僕がつくった48個のWebサービス達
yusukebe
18
17k
Vue.js学習の振り返り
hiro_xre
2
130
VR HMDとしてのVision Pro+ゲーム開発について
yasei_no_otoko
0
100
Universal Linksの実装方法と陥りがちな罠
kaitokudou
1
220
macOS でできる リアルタイム動画像処理
biacco42
7
1.8k
Identifying User Idenity
moro
6
7.8k
Why Spring Matters to Jakarta EE - and Vice Versa
ivargrimstad
0
960
Kotlin2でdataクラスの copyメソッドを禁止する/Data class copy function to have the same visibility as constructor
eichisanden
1
130
Realtime API 入門
riofujimon
0
110
現場で役立つモデリング 超入門
masuda220
PRO
12
2.9k
生成 AI を活用した toitta 切片分類機能の裏側 / Inside toitta's AI-Based Factoid Clustering
pokutuna
0
570
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
504
140k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
The Art of Programming - Codeland 2020
erikaheidi
51
13k
Adopting Sorbet at Scale
ufuk
73
9k
Speed Design
sergeychernyshev
24
570
Writing Fast Ruby
sferik
626
61k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
What's in a price? How to price your products and services
michaelherold
243
12k
The Cult of Friendly URLs
andyhume
78
6k
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 γϯϓϧ͞ΛอͪͭͭɺͲ͜·Ͱڞ௨ԽͰ͖Δ͔͕ޣຯͳͷ ͰɺͦΕΛָ͠Έ·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ