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.2k
testcache.pdf
timakin
1
130
How Go cache
timakin
1
66
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
快速入門可觀測性
blueswen
0
330
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
130
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
920
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
From Translations to Multi Dimension Entities
alexanderschranz
2
130
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
140
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
たのしいparse.y
ydah
3
120
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
Featured
See All Featured
Navigating Team Friction
lara
183
15k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Become a Pro
speakerdeck
PRO
26
5k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Done Done
chrislema
181
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
Making Projects Easy
brettharned
116
5.9k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
A Philosophy of Restraint
colly
203
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
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 γϯϓϧ͞ΛอͪͭͭɺͲ͜·Ͱڞ௨ԽͰ͖Δ͔͕ޣຯͳͷ ͰɺͦΕΛָ͠Έ·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ