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
63
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
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
Contemporary Test Cases
maaretp
0
130
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
150
Ethereum_.pdf
nekomatu
0
460
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Click-free releases & the making of a CLI app
oheyadam
2
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
Outline View in SwiftUI
1024jp
1
320
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
Arm移行タイムアタック
qnighy
0
310
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
580
Featured
See All Featured
How to Ace a Technical Interview
jacobian
276
23k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
What's in a price? How to price your products and services
michaelherold
243
12k
Being A Developer After 40
akosma
86
590k
Designing for Performance
lara
604
68k
Statistics for Hackers
jakevdp
796
220k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Fireside Chat
paigeccino
34
3k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Designing Experiences People Love
moore
138
23k
The World Runs on Bad Software
bkeepers
PRO
65
11k
The Language of Interfaces
destraynor
154
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 γϯϓϧ͞ΛอͪͭͭɺͲ͜·Ͱڞ௨ԽͰ͖Δ͔͕ޣຯͳͷ ͰɺͦΕΛָ͠Έ·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ