Slide 1

Slide 1 text

Win Testing Trophy Easily ςεςΟϯάτϩϑΟʔΛ֫ಘ͢Δ খࢁ݈Ұ࿠ / GMO PEPABO inc. 2023.3.24 PHPerKaigi 2023 1

Slide 2

Slide 2 text

ࣗݾ঺հ ٕज़෦ɹٕज़ج൫νʔϜ 2018೥ த్ೖࣾ খࢁ ݈Ұ࿠ Ken’ichiro Oyama গ࣮͠༻తͰখ͞ͳOSSΛॻ͘ͷ͕झຯɻ ● GitHub : k1LoW ● Twitter : @k1LoW 2

Slide 3

Slide 3 text

GMOϖύϘʹ͍ͭͯ 3 https://pepabo.com

Slide 4

Slide 4 text

4 • https://github.com/k1LoW/tbls • CIϑϨϯυϦͳσʔλϕʔευΩϡϝϯτੜ ੒πʔϧ • PostgreSQL, MySQLͳͲͷRDBMS͚ͩͰͳ ͘ɺBigQuery΍Amazon DynamoDB, Cloud Spannerͱ͍ͬͨσʔλιʔεʹ΋ରԠ • υΩϡϝϯτΛॆ࣮ͤ͞Δػೳͱͯ͠ϝλ σʔλΛΞϊςʔγϣϯ͢Δ͜ͱ͕Մೳ • ςʔϒϧɺΧϥϜͳͲͷίϝϯτ෇༩͚ͩͰ ͳ͘λάɺϦϨʔγϣϯͳͲ tbls ࡞͍ͬͯΔOSS঺հ

Slide 5

Slide 5 text

• https://github.com/k1LoW/octocov • ίʔυϝτϦΫεπʔϧ…ίʔυΧόϨοδɺCode to Test Ratioɺςετ࣮ߦ࣌ؒ • ଟ਺ͷϓϩάϥϛϯάݴޠͱɺओཁͳΧόϨοδϨϙʔτϑΥʔϚοτʹରԠ • GitHub Actionsͷactionͱͯ͠ίʔυϝτϦΫεΛूܭɺP/RίϝϯτɺϨϙʔτ • CLIπʔϧͱͯ͠ίʔυΧόϨοδΛूܭɻදࣔ • ΧόϨοδόοδੜ੒ octocov 5 5 ࡞͍ͬͯΔOSS঺հ

Slide 6

Slide 6 text

6 ίϥϜ঺հ PHPerKaigi 2023ͷύϯϑϨοτʹίϥϜܝࡌͤͯ͞΋Β͍ͬͯ·͢

Slide 7

Slide 7 text

ΞδΣϯμ • ςετߏ੒ • ςεταΠζ • ςετର৅ΞϓϦέʔγϣϯͷཁ݅ͱΞʔΩςΫνϟ • ςετઓུΛߟ͑Δ • ςετઓུΛ࣮ݱ͢ΔͨΊͷ࢓૊Έ • ͓ΘΓʹ 7

Slide 8

Slide 8 text

ΞδΣϯμ 8 ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯ • ຊൃදʹ͓͚Δςετʹؔ͢Δઆ໌΍ߟ ͑ํʹ͓͍ͯɺଟ͘ͷՕॴͰҾ༻ͤͯ͞ ΋Β͍ͬͯ·͢ɻ • ࢲ͕આ໌͢ΔΑΓͣͬͱྑ͍ɻ • ΑΓՁ஋ͷߴ͍ςετΛॻ͘͜ͱΛߟ͑ ΔػձΛ༩͑ͯ͘Ε·͢ɻ • ඇৗʹΦεεϝͰ͢ɻ

Slide 9

Slide 9 text

9 ςετߏ੒

Slide 10

Slide 10 text

10 ςετߏ੒ ςετϐϥϛουʢTest pyramid / The Test Automation Pyramidʣ https://www.mountaingoatsoftware.com/blog/the-forgotten-layer- of-the-test-automation-pyramid Mike Cohn ʮSucceeding with Agile: Software Development Using Scrumʯ

Slide 11

Slide 11 text

ςετɾϐϥϛου͸ɺςετɾεΠʔτʹ͓͍ͯɺ࣍ͷҟͳΔछྨͷς ετ͕ͦΕͧΕಛఆͷׂ߹ͰςετɾέʔεΛ࣋ͭΑ͏ʹͳ͍ͬͯΔɺͱ͍ ͏͜ͱΛఏএ͍ͯ͠Δ֓೦Ͱ͢ɻ • ୯ମςετʢUnitςετ ※ൃදऀ௥ه ʣ • ౷߹ʢintegrationʣςετ • E2EʢEnd-to-Endʣςετ ʢதུʣ ͜ͷςετɾϐϥϛουͷԣ෯͸ςετɾεΠʔτΛߏ੒͢Δ֤छྨͷς ετͷʹؚ·ΕΔςετɾέʔεͷ਺Λࣔ͠·͢ɻͦͷͨΊɺςετɾϐϥ ϛουͷͦ͏͕ԣʹ௕͍΋ͷ΄Ͳɺςετɾέʔε͕ଟ͍͜ͱʹͳΓ·͢ɻ ࣍ʹɺςετɾϐϥϛουͷߴ͞͸ɺର৅ͷςετ͕ͲΕ͘Β͍ΤϯυϢʔ βͷࢹ఺ʹ͍ۙͷ͔Λࣔ͠·͢ɻ 11 Vladimir Khorikov (ஶ), ਢాஐ೭ (຋༁)ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯΑΓ “

Slide 12

Slide 12 text

• React Testing Libraryͷ࡞ऀͰ͋ΔKent C. Doddsࢯ͕ࣔͨ͠ίϯηϓτ • ֤ςετ͝ͱͷ෯͕ςετϐϥϛουͱҟͳΔ • ౷߹ʢintegrationʣςετͷ෯͕େ͖͍
 ʹʢ୯७ʹ͸ʣέʔε਺͕ଟ͍ɺॏ఺తʹ ࡞੒͢ΔΠϝʔδ 12 ςετߏ੒ ςεςΟϯάτϩϑΟʔʢTesting trophyʣ https://kentcdodds.com/blog/the-testing-trophy-and-testing-classifications 
 https://twitter.com/kentcdodds/status/960723172591992832

Slide 13

Slide 13 text

13 “One thing that it doesn't show though is that as you move up the pyramid, the confidence quotient of each form of testing increases. (snip) Integration tests strike a great balance on the trade-offs between confidence and speed/expense. This is why it's advisable to spend most (not all, mind you) of your effort there. ͔͠͠ɺϐϥϛουͷ্ʹߦ͘΄ͲɺͦΕͧΕͷςετͷ৴པࢦ਺͕ߴ͘ͳΔ͜ͱ͸ɺ ͜ͷਤͰ͸ࣔ͞Ε͍ͯ·ͤΜɻ 
 ʢதུʣ ౷߹ςετ͸ɺ৴པੑͱ଎౓ɾඅ༻ͷτϨʔυΦϑͷόϥϯεΛ͏·͘ͱ͍ͬͯ·͢ɻ͜ ͷͨΊɺ΄ͱΜͲͷ࿑ྗΛͦ͜ʹඅ΍͢͜ͱ͕ਪ঑͞Ε·͢ (͢΂ͯͰ͸͋Γ·ͤΜ͕)ɻ https://kentcdodds.com/blog/write-tests ΑΓൈਮɺ຋༁

Slide 14

Slide 14 text

14 ςετߏ੒ ςετͷछྨ • ୯ମςετʢϢχοτςετʣ΍౷߹ςετɺE2EςετͦΕͧΕʹ͍ͭͯ͜Εͩͱ͍͏ఆٛ͸ͳ͍ • ͦͷ݁Ռɺೝ͕ࣝͣΕͯ͠·͏͜ͱ͕͋Δʢ͠ɺଟ͍ʣ • ॻ੶ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯͰ͸୯ମςετͱ౷߹ςετΛ࣍ͷΑ͏ʹఆ͍ٛͯ͠Δ • ୯ମςετ͸ʮ1୯ҐͷৼΔ෣͍Λݕূ͢Δ͜ͱʯʮ࣮ߦ͕࣌ؒ୹͍͜ͱʯʮଞͷςε τɾέʔε͔Βִ཭͞Εͨঢ়ଶͰ࣮ߦ͞ΕΔ͜ͱʯͷ3ͭͷੑ࣭Λ࣋ͭ • 3ͭͷੑ࣭ͷ͏ͪ1ͭͰ΋ଛͳ͍ͬͯΔ΋ͷΛ౷߹ςετʹ෼ྨ͢Δ • ͨͩ͠ɺ্هఆٛͰ΋શ͕ͯ໌֬ʹͳΔ΋ͷͰ͸ͳ͘ɺྫ͑͹ʮִ཭͞Εͨঢ়ଶʯʹ͍ͭͯݹయ ֶ೿ͱϩϯυϯֶ೿Ͱߟ͑ํ͕ҟͳΔ

Slide 15

Slide 15 text

15 ςεταΠζ

Slide 16

Slide 16 text

16 ςεταΠζ ςεταΠζ • ςετͷ࣮ߦ଎౓ͱܾఆੑʹண໨ͨ͠ςετ෼ྨ • ॻ੶ʮGoogleͷιϑτ΢ΣΞΤϯδχΞϦϯάʯΑΓ • ʮ࣮ߦ଎౓͕े෼ʹ଎ͯ҆͘ఆͨ͠ʢِཅੑ΍ِӄੑ͕ͳ͍ʹܾఆੑ͕͋ΔʣςετͳΒ͍͘Β͋ͬ ͯ΋ྑ͍ʯΘ͔Δ • Smallςετʢখςετʣ... ୯ҰϓϩηεʢγϯάϧεϨουʣ಺Ͱ࣮ߦ͞Εͳ͚Ε͹ͳΒͳ͍ɻsleepې ࢭɻI/OېࢭɻϒϩοΫېࢭ • Midiumςετʢதςετʣ... ୯ҰϚγϯ಺Ͱ࣮ߦ͞Εͳ͚Ε͹ͳΒͳ͍ɻlocalhostҎ֎ͷγεςϜ΁ͷωο τϫʔΫݺͼग़͠ېࢭ • Largeςετʢେςετʣ... ෳ਺Ϛγϯʹ·͕ͨΔςετ • ΑΓఆ͕ٛ͸͖ͬΓ͍ͯ͠ΔͷͰɺೝࣝΛἧ͑ΔͨΊʹຊൃදͰ͸ςεταΠζΛ࢖ͬͨઆ໌ΛࢼΈΔ

Slide 17

Slide 17 text

17 ςεταΠζ ૝ఆΞϓϦέʔγϣϯͱςεταΠζͷΠϝʔδ • ઐ༻ͷDBΛ࣋ͪଞͷίϯϙʔωϯτͱ࿈ ಈ͠ͳ͕Βಈ͘APIαʔό • Smallςετ͸ςετର৅͕APIαʔό಺ ෦ • Mediumςετ͸APIαʔόઐ༻DB·Ͱ Λςετσʔλϕʔεͱͯ͠༻ҙ • Largeςετ͸ίϯϙʔωϯτશମͷಈ ࡞͕ର৅

Slide 18

Slide 18 text

18 ςεταΠζ ςεταΠζ + ςετϐϥϛου • ςεταΠζͰςετϐϥϛουΛදݱ • ૝ఆΞϓϦέʔγϣϯʹ͓͍ͯɺςετϐϥ ϛου͕࣋ͭ෯ͱߴ͞ͷҙຯ͸ͦͷ··ʮ͋Δ ఔ౓͍͋ͬͯΔʯͱݴ͑ͦ͏ • γεςϜશମͷಈ࡞Λର৅ͱ͢ΔLargeςε τͷํ͕ϢʔβʹΑΓʹ͍ۙ

Slide 19

Slide 19 text

• ςεταΠζͰςεςΟϯάτϩϑΟʔΛදݱ • SmallςετΑΓMidiumςετΛॏࢹͨ͠ߏ੒ ʹͳΔ • ͱ͜ΖͰɺKentࢯͷݴ͏౷߹ςετͷ۩ମྫͷ1 ͭ͸ʮReactͰ࡞੒ͨ͠ϖʔδશମʢෳ਺ͷReact ίϯϙʔωϯτͷू߹ʣͷςετʯͳͷͰɺ୯Ұ ϓϩηεͰ࣮ߦͰ͖ͯ͠·͏ͨΊɺࢯͷ૝ఆͱ ͍͋ͬͯΔͱ͸ݴ͑ͳ͍ • ςεταΠζͰߟ͑ΔͱKentࢯͷςετߏ੒͸ς ετϐϥϛουͱ͍͑Δ 19 ςεταΠζ ςεταΠζ + ςεςΟϯάτϩϑΟʔ

Slide 20

Slide 20 text

20 ςεταΠζ ྑ͍ςετ • ॻ੶ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯʹΑΔͱɺ
 ʮྑ͍ʢ୯ମʣςετΛߏ੒͢Δ4ຊͷபʯ͸࣍ͷ4ͭ 1. ୀߦʢregressionʣʹର͢Δอޢ 2. ϦϑΝΫλϦϯά΁ͷ଱ੑ 3. ਝ଎ͳϑΟʔυόοΫ 4. อकͷ͠΍͢͞ • ʮୀߦʹର͢ΔอޢʯʮϦϑΝΫλϦϯά΁ͷ଱ੑʯʮਝ଎ ͳϑΟʔυόοΫʯ͸ޓ͍ʹഉ൓͢Δੑ࣭ͳͷͰશͯΛ੒Γ ཱͨͤΔ͜ͱ͸Ͱ͖ͳ͍ • ྑ͍ςετΛ࡞ΔͨΊʹόϥϯεΛௐ੔͢Δඞཁ͕͋Δ Vladimir Khorikov (ஶ), ਢాஐ೭ (຋༁)ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯΑΓ

Slide 21

Slide 21 text

21 ςεταΠζ औΕΔςετઓུ • ʮϦϑΝΫλϦϯά΁ͷ଱ੑʯͱʮอकͷ͠΍͢͞ʯΛՄೳͳݶΓඋ͑ͨ͏͑ͰʮϦϑΝΫλϦϯά΁ ͷ଱ੑʯͱʮਝ଎ͳϑΟʔυόοΫʯͱͷ2ͭͷؒͰόϥϯεΛௐ੔͢Δͷ͕ݱ࣮తͳઓུͱͳΔɻ Vladimir Khorikov (ஶ), ਢాஐ೭ (຋༁) ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯΑΓ

Slide 22

Slide 22 text

• Largeςετ > Midiumςετ > SmallςετͷॱͰʮୀߦʹର͢Δอޢʯ͸ڧྗʹͳ Δ͕ɺอकʹ͔͔Δίετ΋্͕Δ͠ɺਝ଎ͳϑΟʔυόοΫ͸ಘΒΕͳ͍ɻ • ͔ͩΒɺอकίετͱਝ଎ͳϑΟʔυόοΫΛߟ͑Δͱςετέʔεͷ਺͸Smallς ετ > Midiumςετ > LargeςετͷॱͰखް͍ͯ͘͘͠ͱྑ͍ɺͱ͍͏ઓུ • LargeςετΛબ୒͢Δͷ͸Midiumςετ΍SmallςετͰ͸อޢͰ͖ͳ͍ςε τର৅͕͋Δ৔߹ͳͲͳͷͰɺඞવతʹগͳ͘ͳΔ • Ref: https://www.mountaingoatsoftware.com/blog/the-forgotten-layer-of-the-test- automation-pyramid 22 ςεταΠζ ςεταΠζͰߟ͑Δςετϐϥϛουͷςετઓུ

Slide 23

Slide 23 text

• ʢ஫ҙɿKentࢯ͸ςεταΠζͷ෼ྨͰ͸ओு͍ͯ͠ͳ͍ʣ • ʮ৴པੑ㲈඼࣭อূ㲈ୀߦʹର͢Δอޢʯͷ؍఺͕ॏཁ • Largeςετ > Mediumςετ > SmallςετͷॱͰςετͷ৴པࢦ਺ʢ඼࣭อ ূ΁ͷߩݙ౓ʣ͸ߴ͘ͳΔ • ͱ͸͍͑LargeςετΛॏࢹ͢Δͱʮਝ଎ͳϑΟʔυόοΫʯ͕ແʹ… • ʮ৴པੑ㲈඼࣭อূ㲈ୀߦʹର͢Δอޢʯͷ؍఺ͰɺMediumςετ͸τϨʔυΦϑ ͷόϥϯεΛ͏·͘ͱ͍ͬͯΔͷͰɺMediumςετʹॏ఺Λஔ͘ͱ͍͏ઓུ 23 ςεταΠζ ςεταΠζͰߟ͑ΔςεςΟϯάτϩϑΟʔͷςετઓུ

Slide 24

Slide 24 text

24 લ൒·ͱΊ

Slide 25

Slide 25 text

• લఏ΍ೝࣝΛἧ͑ΔͨΊʹςεταΠζΛ࢖ͬͯςετߏ੒ͦΕͧΕͷςετઓུ ͷҧ͍ʹ͍ͭͯઆ໌ΛࢼΈͨɻ • ςετϐϥϛου͸ςεταΠζͰଊ͑௚ͯ͠Έͯ΋΄ͱΜͲͷΞϓϦέʔγϣϯ ʹͱͬͯޮՌΛൃش͢Δߏ੒ʢׂ߹ʣͰ͸͋Δ͕ɺ͋͘·Ͱʮ΄ͱΜͲʯͰ͋ͬͯ શͯͰ͸ͳ͍ɻ • ʮྑ͍ʢ୯ମʣςετΛߏ੒͢Δ4ຊͷபʯͱςετର৅ͷঢ়گ΍ϑΣʔζ΍։ൃମ ੍ͳͲɺ͞·͟·ͳύϥϝʔλΛݟͯ൑அ͍ͯ͘͜͠ͱ͕ॏཁ 25 લ൒·ͱΊ ςετߏ੒ͷ࠷దղ͸ςετϐϥϛου1୒Ͱ͸ͳ͍

Slide 26

Slide 26 text

ςετର৅ΞϓϦέʔγϣϯͷ ཁ݅ͱΞʔΩςΫνϟ 26

Slide 27

Slide 27 text

• ৽ن։ൃͷAPIαʔό • ผͷίϯϙʔωϯτ͔Βݺͼग़͞ΕΔɻ֎෦ίϯϙʔωϯτΛݺͿɻ • ѻ͏υϝΠϯ͸γϯϓϧͰυϝΠϯϩδοΫ΋ͦ͜·ͰෳࡶͰ͸ͳ͍ • ʢͲͷυϝΠϯ΋ͦ͏͕ͩʣσʔλͷऔΓѻ͍͸৻ॏʹߦ͏ඞཁ͕͋Δɻ • υϝΠϯ͸γϯϓϧ͕ͩখ͞ͳ௥Ճ͕͋Γͭͭ΋௕ظӡ༻Λ૝ఆ • ಈ࡞؀ڥ͸ίϯςφϕʔεʢKubernetes্͔ύϒϦοΫΫϥ΢υͷCaaS্ʣΛ૝ఆ 27 ςετର৅ΞϓϦέʔγϣϯͷཁ݅ͱΞʔΩςΫνϟ ςετର৅ΞϓϦέʔγϣϯ

Slide 28

Slide 28 text

• ։ൃݴޠͱͯ͠GoΛબ୒ • APIͷఆٛʹOpenAPI Spec v3Λ࠾༻͠εΩʔϚۦಈ։ൃΛߦ͏ • OpenAPI Document͔Βαʔό/ΫϥΠΞϯτͷίʔυΛࣗಈੜ੒ͯ͠࢖༻ • APIαʔόઐ༻ͷӬଓԽྖҬͱͯ͠γϯϓϧʹRDBMSΛ࠾༻ • ΠϛϡʔλϒϧϞσϧͷߟ͑ํΛ΋ͱʹσʔλϞσϦϯάΛ࣮ࢪ • ʢݱ࣌఺ͷ։ൃن໛ʣAPIύε਺38ɺςʔϒϧ਺92 28 ςετର৅ΞϓϦέʔγϣϯͷཁ݅ͱΞʔΩςΫνϟ ΞʔΩςΫνϟ/։ൃํ਑

Slide 29

Slide 29 text

29 ςετઓུΛߟ͑Δ

Slide 30

Slide 30 text

• ࣗಈςετΛؚΉςετεΠʔτͷ༻ҙ͸ૣ͚Ε͹ૣ͍΄ͲಘΒΕΔޮՌ͕େ͖͍ • େ఍ͷΞϓϦέʔγϣϯ͸௕ظӡ༻͢Δ͜ͱΛ๬ΜͰ͍Δ͕ɺࠓճʮ௕ظӡ༻͢ Δʯͱ͍͏ཁ͕݅͋Δ͜ͱͰΑΓڧ͘ҙࣝ • ։ൃॳظʹʮ௕ظతʹޮՌ͕࣋ଓ͢ΔςετεΠʔτΛߏஙͰ͖Ε͹ΑΓޮՌ͕େ ͖͍ͷͰ͸ͳ͍͔ʯͱ͍͏ʢएׯແ๳ͳʣݕ౼ • ͪͳΈʹ͜ͷݕ౼Λ࢝Ίͨஈ֊Ͱ͸ಈ͘΋ͷ͸Կ΋ͳ͔ͬͨ 30 ςετઓུΛߟ͑Δ ΞϓϦέʔγϣϯͷςετઓུΛ։ൃॳظʹߟ͑Δ

Slide 31

Slide 31 text

• ໋୊ʮ௕ظతʹޮՌ͕࣋ଓ͢ΔςετεΠʔτʯ • ௕ظతʹ࢒Δ΋ͷΛத৺ʹςετΛߏ੒͍͚ͯ͠͹ޮՌ΋࣋ଓ͢Δ͸ͣ • ֎෦ͱͷΠϯλʔϑΣʔεͰ͋ΔAPIεΩʔϚ͸ʁ • ֎෦ͱͷ઀఺͕͋ΔҎ্͸APIͷߋ৽͕͋Γͭͭ΋࢒Δ͸ͣ • σʔλϕʔεʢεΩʔϚʣ͸ʁ • ʮσʔλϕʔεͷण໋͸ΞϓϦέʔγϣϯΑΓ΋௕͍ʯby ીࠜ૖େ aka ͦʔ͍ͩ • Ͱ͸ɺΞϓϦέʔγϣϯͷ࣮૷͸ʁ 31 ςετઓུΛߟ͑Δ ௕ظతʹςετͷՁ஋Λҡ࣋͢ΔͨΊʹ

Slide 32

Slide 32 text

• ࠾༻ͨ͠ύοέʔδʢϥΠϒϥϦʣ͕௕ظతʹϝϯςφϯε͞ΕΔͷ͔͸Θ͔Βͳ͍ • େମΛඪ४ύοέʔδʹدͤͨɻ͕ɺͦΕͰ΋༗໊ύοέʔδͷΞʔΧΠϒͷӨڹΛड͚ͨ • ͜Ε͸ࣗ෼ୡͰϝϯςφϯε͍͚ͯ͠͹ྑ͍ • ࠾༻ͨ͠ΞϓϦέʔγϣϯΞʔΩςΫνϟ͕௕ظతʹ࣋ଓ͢Δ͔Θ͔Βͳ͍ • Ͳ͏͍͏ΞʔΩςΫνϟ͕௕ظతʹྑ͍ͷ͔Θ͔Βͳ͍ • ͦ΋ͦ΋౰࣌͸։ൃॳظͰΞʔΩςΫνϟͷݕ౼΋Ͱ͖͍ͯͳ͍ • Θ͔Βͳ͍ofΘ͔Βͳ͍ • ʢ௕ظӡ༻ʹ଱͑ΒΕΔ͔ͱ͍͏؍఺Ͱʣࣗ෼͕ࠓ͔Βઃܭ͢ΔΞϓϦέʔγϣϯ͕ઃܭ͢Δલ ͔Βطʹ৴༻Ͱ͖ͳ͍ 32 ςετઓུΛߟ͑Δ ΞϓϦέʔγϣϯ͕৴༻Ͱ͖ͳ͍

Slide 33

Slide 33 text

33 ςετઓུΛߟ͑Δ ςετର৅ͷΞϓϦέʔγϣϯͱςεταΠζ • ςετର৅ΞϓϦέʔγϣϯͱςεταΠζͷؔ܎͸࣍ͷΑ͏ͳਤʹͳΔʢ࣮͸લ൒ͱಉ͡ʣ

Slide 34

Slide 34 text

34 ςετઓུΛߟ͑Δ ςετର৅ͷΞϓϦέʔγϣϯͱςεταΠζ • ࣋ଓੑͱ͍͏؍఺Ͱ͍͏ͱʢಛʹ։ൃॳظʹ͓͍ͯʣSmallςετ͸·ͩݻఆతͰ͸ͳ͍

Slide 35

Slide 35 text

35 ςεςΟϯάτϩϑΟʔ

Slide 36

Slide 36 text

• ΞϓϦέʔγϣϯͷ֎͔Βͷςετʹॏ఺Λஔ͘͜ͱͰΞϓϦέʔγϣϯͷ࣮૷ͷมԽʹ Өڹ͞Εʹ͍͘ςετߏ੒ʹ͢Δ • σʔλϕʔε͸ϓϩηε֎ґଘͰ͸͋Δ͕ςετର৅ͷΞϓϦέʔγϣϯ͔Β͔͠Ξ Ϋηε͸ͳ͍ͨΊͦͷ··࢖༻→Mediumςετ • LargeςετʹͳΓ͏Δϝʔϧૹ৴΍֎෦API࿈ܞͳͲ͸ϞοΫΛ࢖༻ • ࣮ࡍʹAPIʹHTTPϦΫΤετΛૹ৴ͯ͠ҙਤͨ݁͠Ռ΍ঢ়ଶʹͳ͍ͬͯΔ͔Λ֬ೝ͢Δ • ҙਤͨ݁͠ՌʹϨεϙϯε • ʮ࣭ͷྑ͍ςετ͸࣮૷ͷৄࡉͰ͸ͳ͘ɺ࠷ऴతͳ݁ՌΛ֬ೝ͢Δʯ • ҙਤͨ͠ঢ়ଶʹσʔλϕʔεͷ஋ 36 ςετઓུΛߟ͑Δ ςεςΟϯάτϩϑΟʔΛ࠾༻

Slide 37

Slide 37 text

37 ςετઓུΛ࣮ݱ͢ΔͨΊͷ ࢓૊Έ

Slide 38

Slide 38 text

• Mediumςετͷίετ͕Smallςετʹൺ΂ͯେ͖͍ • ςετͷ࣮ߦίετʢʮਝ଎ͳϑΟʔυόοΫʯʣ • ҰൠతʹMediumςετ͸SmallςετΑΓ࣮ߦ͕࣌ؒ௕͘ͳΓ͕ͪ • →ςετͷฒߦ࣮ߦͷ࢓૊ΈͰ؇࿨ͭͭ͠΋ɺ͋Δҙຯڐ༰͢Δ • ςετͷ࡞੒ɾอकίετʢʮอकͷ͠΍͢͞ʯʣ • ʮAPIʹHTTPϦΫΤετΛૹ৴ͯ͠ҙਤͨ݁͠Ռ΍ঢ়ଶʹͳ͍ͬͯΔ͔Λ֬ೝ ͢ΔʯςετΛॻ͘͜ͱ͕୯७ʹ໘౗ • →Ͱ͖ΔݶΓ؆୯ʹॻ͚Δ࢓૊ΈΛߏங͢Δ͜ͱͰର߅͢Δ 38 ςετઓུΛ࣮ݱ͢ΔͨΊͷ࢓૊Έ ςεςΟϯάτϩϑΟʔͷ՝୊ͱͦͷ՝୊΁ͷର߅खஈ

Slide 39

Slide 39 text

39

Slide 40

Slide 40 text

• runn ( means "Run N". is pronounced /rʌ́n én/. ) is a package/tool for running operations following a scenario. • γφϦΦΛYAMLͰॻ͍ͯͦΕΛ΋ͱʹૢ࡞ʢΦϖϨʔγϣϯʣΛࣗಈԽͰ͖Δύο έʔδ/πʔϧ • ίϚϯυʢrunnίϚϯυʣͱͯ͠ʢ΋ɺGoͷύοέʔδͱͯ͠΋ʣ࢖͑Δ • runn run [γφϦΦσΟϨΫτϦ]/*.yml • ʮΦϖϨʔγϣϯࣗಈԽʯͱ޿ൣғΛλʔήοτʹ͍ͯ͠Δ͕ɺAPIͷγφϦΦς ετ͕ϑΝʔετϓϥΠΦϦςΟͳϢʔεέʔεʢ։ൃͷ͖͔͚ͬͰ΋͋ΔͨΊʣ 40 https://github.com/k1LoW/runn runn

Slide 41

Slide 41 text

• 1όΠφϦͷγφϦΦ࣮ߦͷCLIίϚϯυʢπʔϧʣͱͯ͠࢖༻Ͱ͖Δ • 1όΠφϦ = CIϑϨϯυϦ • ͞·͟·ͳϓϩτίϧʹରԠ͓ͯ͠Γɺ1ͭͷγφϦΦ಺Ͱෳ਺૊Έ߹ΘͤΔ͜ͱ͕Մೳ • HTTP • gRPC • DatabaseʢSQLʣ • Chrome DevTools Protocol • ೚ҙίϚϯυͷ࣮ߦʢϩʔΧϧ/SSHʣ • GoͷTest Helperʢύοέʔδʣͱͯ͠࢖༻Ͱ͖Δ 41 https://github.com/k1LoW/runn runnͷಛ௃ʢv0.64.1ʣʢ1/2ʣ

Slide 42

Slide 42 text

42 https://github.com/k1LoW/runn runnͷಛ௃ʢv0.64.1ʣʢ2/2ʣ • γφϦΦϑΝΠϧʢYAMLʣͷϑΥʔϚοτ͕OpenAPI SpecϥΠΫ • γφϦΦ಺ͷεςοϓؒͷ஋͕ࣗಈͰ࿈ܞ͞Ε͍ͯΔ • ʮεςοϓAΛ࣮ߦ͔ͯ͠Βͦͷ݁ՌΛ࢖ͬͯεςοϓBΛ࣮ߦ͢Δʯͱ͍͏γφϦΦΛߏங͠΍͍͢ • ෳ਺ͷγφϦΦͷ࣮ߦΛ૝ఆ࣮ͨ͠૷ • ෳ਺ͷγφϦΦͷ෼ׂ࣮ߦɺαϯϓϦϯά࣮ߦɺϥϯμϜ࣮ߦɺฒߦ࣮ߦͳͲ͕Մೳ • ϧʔϓ࣮ߦ΍ϦτϥΠ࣮ߦͷ࢓૊Έ͕૊ΈࠐΈͰඋΘ͍ͬͯΔ • ಉ͡γφϦΦϑΝΠϧΛ࢖ͬͨෛՙςετʢϩʔυςετʣ͕Մೳ • ίϚϯυΛ runn run ͔Β runn loadt ʹมߋ͢Δ͚ͩɻෳ਺γφϦΦ࣮ߦ΋ͦͷ··Մೳ • γφϦΦ࣮ߦͷϩά΋ه࿥Մೳ • γφϦΦ࣮ߦͷϓϩϑΝΠϧ΋औಘՄೳʢ֤εςοϓͷܦա࣌ؒʣ

Slide 43

Slide 43 text

• runn͸1ͭҎ্ͷγφϦΦΛ࣮ߦͯ͠ɺͦΕͧΕͷ੒ޭ/ࣦഊΛΈΔ • 1ͭͷγφϦΦ͸1ͭҎ্ͷεςοϓ͔Βߏ੒͞Ε͍ͯΔ • 1γφϦΦ1YAMLϑΝΠϧʹͳ͍ͬͯΔʢϥϯϒοΫͱݺΜͰ͍Δʣ • γφϦΦ͝ͱʹϥϯφʔͱݺΜͰ͍Δεςοϓ࣮ߦίϯϙʔωϯτΛఆٛ͠ɺͦͷϥϯφʔΛ࢖֤ͬͯε ςοϓΛ࣮ߦ͍ͯ͘͠ • ϥϯφʔʹ͸γφϦΦ಺ʹఆ͕ٛඞཁͳ௨ৗͷϥϯφʔͱɺطʹrunnͰ༻ҙ͍ͯ͠ΔϏϧτΠϯϥϯφʔͷ2 छྨ͕͋Δ • ϥϯφʔ: HTTPϥϯφʔɺDBϥϯφʔɺgRPCϥϯφʔɺCDPϥϯφʔɺSSHϥϯφʔ • ϏϧτΠϯϥϯφʔ: ExecϥϯφʔɺTestϥϯφʔɺDumpϥϯφʔɺIncludeϥϯφʔɺBindϥϯφʔ 43 https://github.com/k1LoW/runn runnͷΞʔΩςΫνϟ

Slide 44

Slide 44 text

44 γφϦΦʢϥϯϒοΫʣΛॻ͘

Slide 45

Slide 45 text

45 https://github.com/k1LoW/runn

Slide 46

Slide 46 text

46 https://github.com/k1LoW/runn

Slide 47

Slide 47 text

47 https://github.com/k1LoW/runn

Slide 48

Slide 48 text

48 https://github.com/k1LoW/runn

Slide 49

Slide 49 text

49 https://github.com/k1LoW/runn

Slide 50

Slide 50 text

50 https://github.com/k1LoW/runn

Slide 51

Slide 51 text

51 https://github.com/k1LoW/runn

Slide 52

Slide 52 text

52 https://github.com/k1LoW/runn ϥϯφʔͷઃఆ ม਺ͷઃఆ ɹɹɹɹ֤εςοϓ 0 1 2 3

Slide 53

Slide 53 text

53 runn new

Slide 54

Slide 54 text

• γφϦΦϑΝΠϧ࡞੒ͷͨΊͷαϙʔτίϚϯυ • runn newͷҾ਺ʹ஋Λ౉͢͜ͱͰγφϦΦϑΝΠϧΛ࡞੒͢Δ • cURLίϚϯυ • gRPCurlίϚϯυ • ΞΫηεϩά • ʢOpenAPI SpecͷυΩϡϝϯτʁʣ • ʢPostmanͷCollectionʁʣ • طଘͷγφϦΦʹεςοϓͱͯ͠௥Ճ͢Δ͜ͱ΋Մೳ 54 https://github.com/k1LoW/runn runn new

Slide 55

Slide 55 text

55 https://github.com/k1LoW/runn DEMO: https://github.com/k1LoW/runn#quickstart

Slide 56

Slide 56 text

• ࠓճ૝ఆͨ͠MediumςετʢAPI call + DBʣΛSmallςετฒΈʹ؆୯ʹ͢Δπʔϧͱͯ͠ runnΛ։ൃɻ • ςετͷ࣮ߦ࣌ؒ΁ͷର߅ • ฒߦ࣮ߦ΍෼ׂ࣮ߦͷͨΊͷػೳΛఏڙ • ࣮ߦ࣌ؒΛϓϩϑΝΠϧ͢ΔͨΊͷػೳΛఏڙ • ςετͷ࡞੒ɾอकίετ΁ͷର߅ • OpenAPI SpecʢϥΠΫʣɺSQLɺLinuxίϚϯυͳͲɺ௚ײతʹॻ͚ΔΑ͏ʹ͢Δ͜ͱͰ ࡞੒ίετΛܰݮ • Մಡੑͷྑ͔͞ΒAPIૢ࡞αϯϓϧͱͯ͠ͷซ༻ͳͲͰอकίετΛܰݮ 56 ςετઓུΛ࣮ݱ͢ΔͨΊͷ࢓૊Έ πʔϧͰςεςΟϯάτϩϑΟʔͷ՝୊ʹର߅͢Δ

Slide 57

Slide 57 text

• ʢ͋͘·Ͱ1ͭͷࢦඪͱͯ͠ʣ1ͭͷγφϦΦ͋ͨΓͷίʔυΧόϨοδ͕ඇৗʹେ͖͍ͨΊʮϦϑΝΫλϦϯά΁ͷ଱ੑʯ ʮୀߦʹର͢Δอޢʯʹରͯ͠ޮՌ͕େ͖͍ • γφϦΦͷ֦ॆ΋YAMLΛॻ͚ͩ͘Ͱྑ͍ • Ұ౓૊ΈࠐΜͰ͠·͑͹ɺ͋ͱ͸YAMLΛॻ͚ͩ͘ʹͳΔͨΊɺ͔ͳΓḿͬͨɻ • ḿΓ͗ͯ͢ςετ࣮ߦ͕࣌ؒ૿େ͠ɺςετ෼ׂ͕ඞཁʹͳͬͨ • ςετσʔλϕʔεʹ΋ؾܰʹΫΤϦΛൃߦͰ͖ΔͷͰγφϦΦ͕࡞੒͠΍͍͢ • γφϦΦ͕OpenAPI SpecϥΠΫͰ͋Δ͜ͱ͔ΒΤϯδχΞʹͱͬͯಡΈ΍͘͢ɺͦͷ··ΦϯϘʔσΟϯάʹ໾ʹཱͬͨ ʢAPIར༻ଆ΁ͷઆ໌ͳͲʣ • ॻ͖΍͍͢=ಡΈ΍͍͢ • ϫϯόΠφϦͷͨΊΠϯετʔϧ΋؆୯ɻCI΁ͷ૊ΈࠐΈ΋༰қɻ • runnͷόάΛআ͚͹ςετͷܾఆੑ΋୲อͰ͖͍ͯΔ 57 ςετઓུΛ࣮ݱ͢ΔͨΊͷ࢓૊Έ ࣮ࡍͲ͏͔ͩͬͨ

Slide 58

Slide 58 text

• ΞϓϦέʔγϣϯσϓϩΠ௚ޙͷಈ࡞֬ೝͷͨΊͷ؆қతͳϦάϨογϣϯςετͷ ඞཁੑ • ϖύϘ͸͞·͟·ͳٕज़ελοΫͰߏங͞Εͨଟ͘ͷαʔϏεΛӡ༻͍ͯ͠Δ • ؆қͰྑ͍ɻ͔͠͠ɺʮϒϥ΢βϕʔεʯʮ։ൃݴޠʹدΒͳ͍͜ͱʯʮηοτ Ξοϓ͕؆୯Ͱ͋Δ͜ͱʯʮςετ࡞੒ֶ͕शίετ͕খ͍͜͞ͱʯ͕ཁ݅ + Chrome DevTools ProtocolʹରԠ͢Δ͜ͱͰrunnͰ؆қج൫Λߏங • ChromeʢChromiumʣࠐΈͷDocker imageΛ༻ҙ͢Δ͜ͱͰ্هཁ݅Λຬͨͨ͠ • docker pull ghcr.io/k1low/runn:latest 58 ςετઓུΛ࣮ݱ͢ΔͨΊͷ࢓૊Έ ʢ͓·͚ʣ૝ఆ֎ͷϢʔεέʔε: ϦάϨογϣϯςετ

Slide 59

Slide 59 text

͓ΘΓʹ 59

Slide 60

Slide 60 text

• ։ൃॳظʹMediumςετΛް͘͢ΔςετઓུΛͱͬͨ • ʮະ࣮૷ͳΞʔΩςΫνϟʯʮ௕ظతʹ࣋ଓ͢ΔςετεΠʔτʯͳͲͷཁ݅ • Mediumςετͷߏ੒Λେ͖͘͢Δ͜ͱʹΑΔίετ૿ʹର߅͢Δखஈͱͯ͠APIγ φϦΦςεςΟϯάπʔϧ/ΦϖϨʔγϣϯࣗಈԽπʔϧͱͯ͠runnΛ࡞੒ͨ͠ • ݁Ռͱͯ͠ࠓճͷέʔεʹ͓͍ͯ͸े෼ʹຬ଍͕͍͘΋ͷͩͬͨ • ࠓޙɺʮن໛͕େ͖͘ͳΔʯʮΞʔΩςΫνϟ͕҆ఆ͢ΔʯͳͲͷཁҼʹΑΓςε τߏ੒͕ϐϥϛουʹۙͮ͘͜ͱ͸େ͍ʹ͋Γ͏Δ͕ɺগͳ͘ͱ΋ݱ࣌఺ʹ͓͍ͯ ͸ѱ͘ͳ͍൑அͩͬͨ 60 ͓ΘΓʹ Win Testing Trophy Easily!!!

Slide 61

Slide 61 text

͓ΘΓʹ 61 ʮ୯ମςετͷߟ͑ํ/࢖͍ํʯ • ຊൃදʹ͓͚Δςετʹؔ͢Δઆ໌΍ߟ ͑ํʹ͓͍ͯɺଟ͘ͷՕॴͰҾ༻ͤͯ͞ ΋Β͍ͬͯ·͢ɻ • ࢲ͕આ໌͢ΔΑΓͣͬͱྑ͍ɻ • ΑΓՁ஋ͷߴ͍ςετΛॻ͘͜ͱΛߟ͑ ΔػձΛ༩͑ͯ͘Ε·͢ɻ • ඇৗʹΦεεϝͰ͢ɻ

Slide 62

Slide 62 text

͓ΘΓʹ 62 ʮrunn ΫοΫϒοΫʯ • runnͷ࢖͍ํΛ঺հ͢ΔZennϒοΫ • ϨγϐܗࣜͰಋೖ͔Βߴ౓ͳ࢖͍ํ·Ͱ Λऩ࿥ • ෆఆظͰϨγϐΛ௥Ճ΍ฤूΛ͢ΔܗͰ ӡ༻͍ͯ͠·͢ • ༗ྉͰ͕͢ແྉެ։ൣғ΋ଟ͋͘Γ·͢ • https://zenn.dev/k1low/books/runn- cookbook

Slide 63

Slide 63 text

Thank You! Thank You! 63