ãåäœãã¹ãã®èãæ¹/䜿ãæ¹ãVladimir Khorikov https://amzn.to/3BCLytq ã以åèªãã ã
ããã§ãã¹ãã«ã€ããŠèšãããŠãã11ç« 12ç« ãèªãã ãåŒãç¶ããã¹ãã«é¢é£ãã13ç« ã®ããã¹ãããã«ããèªãããšæãã2024幎12æ31æ¥(ç«)ã¹ã¿ãŒããšããã
13ç« ããã¹ãããã«
ãã®ãããªå Žåã«ã¯ããã¹ãããã«ãããã€ããåãã§ããããã¹ãããã« (test double) (https://oreil.ly/vbpiU) ã¯æ ç»å ã§ã¹ã¿ã³ããã³ (stunt double) ã俳åªã®ä»£åœ¹ãåããã®ãšåãããã«ããã¹ãå ã§æ¬ç©ã®å®è£ ã®ä»£åœ¹ãåããããšã®ã§ãããªããžã§ã¯ããŸãã¯é¢æ°ã§ããã
ãŠããããã¹ãã®ããšãåŠã³å§ããæã¯ãã¢ãã¯ãšèšãèšèããå ¥ã£ããããªæãåºãããããŸãã倧äºãªã®ã¯ãªããžã§ã¯ããŸãã¯é¢æ°ã®ã¹ã¿ã³ããã³ã§ãããšããããšã ããããªããžã§ã¯ãã ãã§ã¯ãªããé¢æ°ã
13.1ããã¹ãããã«ã®ããœãããŠã§ã¢éçºãžã®åœ±é¿
ãã¹ãããã«ãå©çšãããšãå€å°ã®ãã¬ãŒããªããèŠããè€éãªåé¡ãããœãããŠã§ã¢éçºã«ããã€ãããããããã âŠç¥âŠ ãã¹ãå¯èœæ§ ãã¹ãããã«ãå©çšããã«ã¯ãã³ãŒãããŒã¹ããã¹ãå¯èœãªããã«èšèšãããŠããªããã°ãªããªãã âŠç¥âŠ å¿çšæ§ ãã¹ãããã«ãé©åã«å©çšããã°ããšã³ãžãã¢ãªã³ã°é床ã«å匷ãæšé²åãå ããããšãã§ãããããã¹ãããã«ãäžé©åã«å©çšãããšããã¹ããèããè€éã§ãå¹æã®å£ããã®ã«ãªãçµæã«é¥ããããªãã âŠç¥âŠ å¿ å®æ§ å¿ å®æ§ã¯ããã¹ãããã«ã®æåã眮æ察象ã®æ¬ç©ã®å®è£ ã®æåã«ã©ãã ãè¿ããšãããŸã§èŠããããŠããããæãã
ãã¹ãããã«ã䜿ãããšãããšãã«çãŸãããã¬ãŒããªãã¯ããã¹ãå¯èœæ§ãå¿çšæ§ãå¿ å®æ§ã
13.2ãGoogleã§ã®ãã¹ãããã«
èŠåŽããªããæã ãåŠãã æèšã«ãã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã䜿ããããã®ã¯å±éºã§ãããšãããã®ãããã âŠç¥âŠ äœå¹Žãçµã¡ãæ°ãåããªãéã®ãã¹ããå®è¡ãããŠåããŠãã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã䜿ã£ããã¹ãã®ä»£åãæã ã¯æãå§ãããã€ãŸãããããã®ãã¹ãã¯ãæžãã®ã¯ç°¡åã ã£ããšã¯ããããã°ãæ» å€ã«çºèŠããªãå²ã«ä¿å®ã®ããã®åŽåãå®åžžçã«å¿ èŠãšãªãããšãèãåããããšãæã ã®åããæ害ã¯å€§ããã£ããGoogle ã®æ¯ãåã¯çŸåšã¯å¥ã®æ¹åã«æ¯ããããã«ãªããå€ãã®ãšã³ãžãã¢ãããçŸå®çãªãã¹ããæžãæ¹ãåªå ããŠã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã®å©çšã¯é¿ããŠããã
ãã¹ãããã«ãã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã¯ã§ããã ã䜿ããªãããã«ããä»æ¹ãªã䜿ãããã«ããŠããã
13.3ãåºæ¬æŠå¿µ
ãã¹ãããã«ã«é¢é£ããåºæ¬æŠå¿µãããã€ãæ±ã£ãŠãããã
楜ãã¿ã
13.3.1ããã¹ãããã«ã®äŸ
ãã¹ãå ã§æ¬ç©ã®ã¯ã¬ãžããã«ãŒããµãŒãã¹ãå©çšããäºã¯å®çŸäžèœã ãã(ãã¹ãå®è¡ã§çãããŸãšãŸã£ãé¡ã®ãã©ã³ã¶ã¯ã·ã§ã³ææ°æãæãæµ®ãã¹ãŠã¿ãŠæ¬²ãã!)ãã ããæ¬ç©ã®ã·ã¹ãã ã®æåãã·ãã¥ã¬ãŒã·ã§ã³ããããã«ã代ããã«ãã¹ãããã«ãå©çšã§ããã ããã
ããã¯ãã¹ãããã«ã®ããããããè¯ãäŸã ã
13.3.2ãã·ãŒã
ã·ãŒã (seam: ç¶ãç®ã https://oreil.ly/pFSFf) ã¯ããã¹ãããã«ãå©çšã§ããããã«ããããšã§ãã³ãŒãããã¹ãå¯èœãšããæ¹æ³ã§ããã âŠç¥âŠ ãã£ãã³ãã³ã·ãŒã€ã³ãžã§ã¯ã·ã§ã³ (dependency injection/DI: äŸåæ§ã®æ³šå ¥ã https://oreil.ly/og9p9) ã¯ã·ãŒã ãå°å ¥ããäžè¬çãªãã¯ããã¯ã§ããã
DIã¯æ¥åžžçã«æŽ»çšããããã·ãŒã ã¯ãªãã¿ã®ãªãèšèã ãã ããã·ãŒã ã®äžéšãšããŠDIãååšãããšããäºã¯ç解ã§ããã
13.3.3ãã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯
Google ã§ã¯ Java åãã«ã¯ Mockito ãC++ åãã«ã¯ Googletest ã® googlemock ã³ã³ããŒãã³ã (https://github.com/google/googletest) ãPython åãã«ã¯ unittest.mock (https://oreil.ly/clzvH) ãçšããŠããã
ãžããã
13.4ããã¹ãããã«å©çšã®ããã®ãã¯ããã¯
ãã¹ãããã«ã®å©çšã«ã¯ã3ã€ã®äž»èŠãªãã¯ããã¯ãååšããã
ãã®3ã€ã䜿ãããªããããã«ãªãã°ããªã匷ããªãããšæãããåäœãã¹ãã®èãæ¹/䜿ãæ¹ãã§ã¯ã第5ç« ã¢ãã¯ã®å©çšãšãã¹ãã®å£ãããããã§æ±ãããŠããããåãèšèãéãæå³ã§äœ¿ãããŠãããã説æã®åãå£ã芳ç¹ãç°ãªã£ãŠãããããã®ã§åçŽãªçŽä»ãã¯ãããŠãããã
13.4.1ããã§ã€ãã³ã°
ãã§ã€ã¯(fake : åœç©)ã¯ãæ¬çªç°å¢ã«ã¯é©ããŠããªãããæ¬ç©ã®å®è£ åæ§ã«æ¯èãAPIã®è»œéãªå®è£ ã§ãããäŸãã°ã¡ã¢ãªãŒå ããŒã¿ããŒã¹ã ã
å®è£ ãäœéã§ãã£ãããçšæãé£ããå Žåã«ãã§ã€ãã³ã°ã䜿ããã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã䜿ã£ãŠããªããŠãããã§ã€ã¯çšã®ã¯ã©ã¹ãå¥éçšæããŠããã°å®çŸã§ããã
ãããŠããã§ã€ã¯ãæžãã®ã¯é£ããå Žåããããããã¯ãã§ã€ã¯ãçŸåšãªãã³ã«å°æ¥ã«ãããŠæ¬ç©ã®å®è£ åæ§ã®æåãæã€ããšãæ ä¿ããªããã°ãªããªãããã ã
ããã匱ç¹ã
13.4.2ãã¹ã¿ãã³ã°
ã¹ã¿ãã³ã° (stubbing : ã¹ã¿ãé©çšã https://oreil.ly/gmShS)ã¯ãæåãäžããããªããã°ããèªäœã§ã¯äœãæåãæããªããããªé¢æ°ã«ãæåãäžããããã»ã¹ã§ãããã€ãŸããé¢æ°ãè¿ãã¹ãæ£ç¢ºãªå€ãé¢æ°ã«å¯ŸããŠæå®ããã®ã (ããªãã¡ãè¿ãå€ãã¹ã¿ã [stub] ãã)ã âŠ ç¥ âŠ èš³æ³š : äžè¬çã«ã¯ãæ¢åã®å¥ã³ãŒãããã€ã³ã¿ãŒãã§ãŒã¹ã®ã¿å®çŸ©ããå®è£ ãæžãã§ããªããœãããŠã§ã¢ã³ã³ããŒãã³ãã®ä»£åœ¹ãåããããšã§äŸåé¢ä¿ãå¶åŸ¡ããã³ãŒããæããããã¹ãã®æèã§ã¯ããã¹ããéãããã«å®çŸ©æžã¿ã®æ±ºãŸã£ãããŒã¿ãæäŸãããã¹ãããã«ãæããããã§ã¯åè©ãšããŠãã®ãããªããŒã¿ãè¿ãããšãæå³ããŠããã
ãããã®é¢æ°ãåŒã°ããããããããå€ãè¿ããŠãããã£ãŠãã奎ãã¹ã¿ãã³ã°ã
13.4.3ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã
ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã(https://oreil.ly/zGfFn) ã¯ãé¢æ°ãã©ã®ããã«åŒã³åºããããããå®éã«ãã®é¢æ°ã®å®è£ ãåŒã³åºãããšãªãã«æ€èšŒããæ¹æ³ã§ãããé¢æ°ãæ£ããæ¹æ³ã§åŒã³åºãããªãå Žåããã¹ãã¯å€±æãã¹ãã ãäŸãã°ãé¢æ°ãå šãåŒã³åºãããªãå ŽåãåŒã³åºãããåæ°ãå€ãããå Žåã誀ã£ãåŒæ°ã§åŒã³åºãããå Žåã§ããã
é¢æ°ã®åŒã³åºãããããæ¹ã®æ€èšŒ ( = ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã) ã§ãã£ãŠãåŒã³åºãããåŸã®çµæã代æ¿ãããã® ( = ã¹ã¿ãã³ã°) ã§ã¯ãªã
13.5ãæ¬ç©ã®å®è£
ãã¹ãããã«ã¯éåžžã«æçšãªãã¹ãããŒã«ãšãªãåŸããããã¹ãã«ã€ããŠã®æã ã®ç¬¬äžã®éžæã¯ããã¹ã察象ã·ã¹ãã ã®äŸåé¢ä¿ã«æ¬ç©ã®å®è£ ãå©çšããããšã ã
ãã®ç« ã¯ããã¹ãããã«ã«ã€ããŠã ãã䜿ããªããŠæžããªãããã1çªè¯ããšèšãçµè«ã
ãã¹ãå ã§æ¬ç©ã®å®è£ ãåªå ããäºã¯ãå€å žçãã¹ã (classical testingã https://oreil.ly/OWw7h) ãšããŠç¥ããããã¢ãã¯äž»çŸ©è ãã¹ã (mockist testing) ãšããŠç¥ããããã¹ãææ³ã®ã¹ã¿ã€ã«ãããããã®ã¹ã¿ã€ã«ã§åªå ãããã®ã¯ãæ¬ç©ã®å®è£ ã®ä»£ããã«ã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã䜿ãããšã§ããã
ãåäœãã¹ãã®èãæ¹/䜿ãæ¹ãã§ã¯å€å žåŠæŽŸãšãã³ãã³åŠæŽŸã§èª¬æãããŠãããGoogleã¯å€å žãŠåŠæŽŸã§ãããå€å žçãã¹ããéèŠããŠããã
13.5.1ãåé¢ããçŸå®ã«å³ããããšãåªå ãã
åé¢ = ãã¹ãããã«ãçŸå® = æ¬ç©ã®å®è£ ã
æã ãçŸå®çãªãã¹ããåªå ããã®ã¯ããã¹ã察象ã·ã¹ãã ãæ£åžžã«åäœããŠãããšããç¹ã§ã®ä¿¡é Œãããå€ãããããã®ããçŸå®çãªãã¹ãã ããã§ããã
ãã¹ãããã«ã䜿ããªãã®ã«è¶ããããšã®ãªãçç±ã¯ããã¹ãã®ä¿¡é Œæ§ã¢ãã (ãããã¯äžããªã) ã®ããã
ã€ãŸãããã¹ãã¯å®è£ ãã©ã®ããã«æ§æãããŠããããšãã芳ç¹ããã§ã¯ãªãããã¹ããããAPIã®èŠ³ç¹ããæžãããã¹ãã ã
å®è£ ã®è©³çŽ°ããã¹ããããã®ã§ã¯ãªããæ¯ãèãããã¹ãããã
æ¬ç©ã®å®è£ ã䜿ããšãæ¬ç©ã®å®è£ ã«ãã°ãååšããå Žåã«ãã¹ãã®å€±æãæãæãããããããã¯è¯ãããšã ïŒãã¹ã倱æã¯æ¬çªç°å¢ã§ã³ãŒããæ£åžžåäœããªãããšã瀺ãããããã®ãããªå Žåã«ã¯ãã¹ãã倱æããã®ã¯æããšããã ã
ãããã£ãèšèã¯åæ°ãããããããã£ãããšãã¹ããæžããŠå€±æãã¹ããšããã§ãã£ãã倱æããã®ã¯è¯ãããšã ã
ã±ãŒã¹ã¹ã¿ã㣠: @DoNotMock
Googleã§ã¯ããã¹ããã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã«é ŒããããäŸãçžåœæ°èŠããããããããã Java ã§ã® @DoNtoMock ã¢ãããŒã·ã§ã³ãäœæããåæ©ãšãªã£ãã»ã©ã ã£ãã âŠç¥âŠ äœæ API ã®ãªãŒããŒãæ°ã«ãããã®ããèŠã¯ã API ãªãŒããŒãé·æçã« API ã®å®è£ ãå€æŽã§ããèœåã«ã API ã®ã¢ãã¯åãèããå¶çŽã課ãã®ã ã
ã¢ãã¯ã«åŒãããããŠãæ¬æ¥ã®APIãã€ã³ã¿ãŒãã§ã€ã¹ãå€æŽã§ããªãããšãçºçããŠããŸã£ããã¢ãã¯ãAPIã®è¶³ãåŒã£åŒµãããããªããšã£ãŠãããã ãªãããã§ããªãã»ã©ã
13.5.2ããã€æ¬ç©ã®å®è£ ã䜿ãã¹ãã決ããæ¹æ³
æ¬ç©ã®å®è£ ãåªå ãããã®ã¯ããããé«éã§ã決å®æ§ã§ãæã£ãŠããäŸåé¢ä¿ãåçŽã§ããå Žåã§ããã
éã«ãã¹ã察象ã¯é«éãªã®ã¯ãšãããã眮ããšããšããŠã決å®æ§ãæãããããã«èšèšããäŸåé¢ä¿ãåçŽã«ããããã«èšèšããŠãå®è£ ãããšãã¹ãã§ããããã«ãªããšãããã
13.5.2.1ãå®è¡æé
çµè«ãšããŠãæ¬ç©ã®å®è£ ãé ãå Žåã¯ããã¹ãããã«ãéåžžã«æçšãšãªãåŸãã âŠç¥âŠ è¿œå ã§ãããæéã劥åœã§ãããã©ããå€æã«è¿·ãç¶æ³ã§ã¯ãé ãããŠäœ¿ããªããªããŸã§æ¬ç©ã®å®è£ ã䜿ãã®ãæ¯èŒçç°¡åãªå Žåãå€ããæ¬ç©ã®å®è£ ã䜿ããªããªã£ããšããã§ä»£ããã«ãã¹ãããã«ã䜿ãããã«ãã®ãã¹ããæŽæ°ããã°è¯ãã
æåãããã¹ãããã«ã䜿ãããšèãã®ã§ã¯ãªããæåã¯æ¬ç©ã䜿ãããã®éãåŸã§ãã¹ãããã«ã«çœ®ãæããããããã«äœããšãããšããããã€ã³ãã«ãªã
13.5.2.2ã決å®æ§
ããã¹ãã決å®æ§ (https://oreil.ly/brxJl) ã§ããããšããã®ã¯ãããããŒãžã§ã³ã®ãã¹ã察象ã·ã¹ãã ã«å¯Ÿãããã®ãã¹ããåžžã«åãçµæã«è³ãæ§è³ªãæããããªãã¡ããã®ãã¹ããåžžã«åæ Œããããåžžã«å€±æãããã§ãããå¯Ÿç §çã«ãããã¹ããé決å®æ§ (https://oreil.ly/5pG0f) ã§ããããšèšãã®ã¯ããã¹ã察象ã·ã¹ãã ãå€åããªããŸãŸã§ãããã«ããããããããã¹ãã®çµæãå€åããããšãããæ§è³ªãæãã
äŸãããªããé¢æ°åããã°ã©ãã³ã°ã®ãããªåªçã§ãããã¹ãã決å®æ§ã§ãããã¹ãã
ä¿¡é Œäžèœæ§ããã¹ãã®å¥å šæ§ã害ããã®ã¯éçºè ããã¹ãã®çµæãçã£ãŠå€±æãç¡èŠãå§ããå Žåã§ããã
ããã¯ãåäœãã¹ãã®èãæ¹/䜿ãæ¹ãã«ãåæ§ã®èšè¿°ããã£ãããã¹ããç¡èŠãããããšã«ç¹ããã®ã§æåããã倱æãããã¯é§ç®ã
ããããä¿¡é Œäžèœæ§ãé »ç¹ã«çºçãããªããæ¬ç©ã®å®è£ ããã¹ãããã«ã§çœ®æããããšã§ãã¹ãã®å¿ å®æ§ãæ¹åããã®ã§ã眮æãè¡ãã¹ãé åããããããªãã
ããã§ãã¹ãããã«ã®åºçªãšãããããã
13.5.2.3ãäŸåé¢ä¿ã®æ§ç¯
çæ³ã®è§£æ³ã¯ããã¹ãå ã®ãªããžã§ã¯ããæåã§æ§ç¯ããã®ã§ã¯ãªãããã¡ã¯ããªãŒã¡ãœãã (factory method) ãããã¯èªåãã£ãã³ãã³ã·ãŒã€ã³ãžã§ã¯ã·ã§ã³ã®ããã«ãæ¬çªç°å¢åãã³ãŒãå ã§å©çšãããŠããã®ãšåããªããžã§ã¯ãæ§ç¯ã³ãŒãã䜿ããã®ã ã
ãã¹ãã«å¿ èŠãªéšåãçæããã®ã«äŸåé¢ä¿ãå€ãå Žåã¯ãããããã¹ããæžãã®ã倧å€ãšããæã«èµ·å ããŠããã
13.6ããã§ã€ãã³ã°
ãã§ã€ã¯ã¯æ¬ç©ã®æ¥ãšåæ§ã«æ¯ãèããããä»ã®ãã¹ãããã«ã®ãã¯ããã¯ãã奜ãŸãããã€ãŸããã¹ã察象ã·ã¹ãã ã«ãšã£ãŠæ¬ç©ã®å®è£ ãšãããšãããŠããã®ãããã§ã€ã¯ãšãããšãããŠããã®ããå€å¥ããããšããã§ããªãç¶æ ã§ããã¹ãã ã
ãã®ç¶æ ãäœãåºãããã«ããã£ãã³ãã³ã·ãŒã€ã³ãžã§ã¯ã·ã§ã³ãªã©ãæ¬ç©ãŸãã¯ãã§ã€ã¯ãå€ããå ¥ãæ¿ããããã®æ段ããããšç解ããŠããã
13.6.1ãäœæ ãã§ã€ã¯ãéèŠãªã®ã
ããªãã¡ããã§ã€ã¯ã®å®è¡ã¯é«éã§ãæ¬ç©ã®å®è£ ãå©çšããéã®æ¬ ç¹ãªãã«å¹æçã«ã³ãŒãããã¹ãã§ããããã«ããŠãããã
ãŸããä»ã®ãã¯ããã¯ããããäžæ確ã§èãå¹æã®äœãããšãã£ãããšããããããã«ãããšèšåããŠããã
13.6.2ãã©ããªå Žåã«ãã§ã€ã¯ãæžãããã¹ãã
ãã§ã€ã¯ã¯æ¬ç©åæ§ã«æ¯ãèããªããã°ãªããªããããäœæã«æ¯èŒçå€ãã®åŽåãšãã¡ã€ã³çµéšãšãèŠããããŸããã§ã€ã¯ã«ã¯ä¿å®ãå¿ èŠã§ããã âŠç¥âŠ ãã§ã€ã¯ãæžãããšãããŒã ãæ€èšããŠãããªãããã§ã€ã¯ã®å©çšããçããçç£æ§ã®æ¹åãããã§ã€ã¯ãæžãä¿å®ããã³ã¹ããäžåããã©ããã«é¢ããŠããã¬ãŒããªããè¡ããªããã°ãªããªãã âŠç¥âŠ ä¿å®ãå¿ èŠãªãã§ã€ã¯ã®æ°ãæžããã«ã¯ãéåžžããã¹ãå ã§ã®å©çšãçŸå®çã§ã¯ãªãã³ãŒããæã€åŒã³åºãããªãŒã®æäžäœããŒã (ã«ãŒã) ã«ãããŠã®ã¿ãã§ã€ã¯ãäœæãã¹ãã ã
ãã¹ããé ãçã§ãã§ã€ã¯ãæ€èšãå§ãããšãããã åã«å°å ¥ããã®ã§ã¯ãªãããã¯ãããŒã ã§ãã¬ãŒããªãããããšããããšãèªèããäžã§å°å ¥ããããšã倧äºã«ãªã£ãŠããã
13.6.3ããã§ã€ã¯ã®å¿ å®æ§
ãã§ã€ã¯ã®äœæããããæãéèŠãªæŠå¿µã¯ãããããå¿ å®æ§ã§ããã âŠç¥âŠ å®å šãªå¿ å®æ§ã¯å¿ ãããå®çŸå¯èœã§ã¯ãªãã âŠç¥âŠ ããããŸãã¯ããã§ã€ã¯ã¯æ¬ç©ã®å®è£ ã®æã€APIå¥çŽãžã®å¿ å®æ§ãç¶æãã¹ãã§ããããã§ã€ã¯ã¯ãAPIã®ã©ããªå ¥åã«å¯ŸããŠãããã®ãã§ã€ã¯ã«å¯Ÿå¿ããæ¬ç©ã®å®è£ ãšåãåºåãè¿ããåãç¶æ å€æŽãå®è¡ãã¹ãã§ããã
å ¥åºåãæãããšèšãäºã
ãŸãå¥ã®å Žæã§èšè¿°ãããããæ³å®å€ã®ã±ãŒã¹ã§ãã§ã€ã¯ãå©çšããããããšããå Žåã¯ããšã©ãŒã«ãããæ©ã ã«å€±æãããã®ãæåãšãããããã¯ãã®éããšæã£ãã
13.6.4ããã§ã€ã¯ã¯ãã¹ããããã¹ãã§ãã
ãã§ã€ã¯ã¯ã察å¿ããæ¬ç©ã®å®è£ ã®APIã«æºæ ããŠããããšãæ ä¿ããããã«ãããèªäœã®ãã¹ããåããªããã°ãªããªãã âŠç¥âŠ ãã§ã€ã¯åãã«ãã¹ããæžãå ŽåãAPIã®å ¬éã€ã³ã¿ãŒãã§ãŒã¹ã«å¯ŸããŠãã¹ããæžããæ¬ç©ã®å®è£ ãšãã§ã€ã¯ã®åæ¹ã«å¯ŸããŠãã®ãã¹ããå®è¡ããããšã䌎ãã¢ãããŒãããã(ãã®ãããªãã¹ãã¯å¥çŽãã¹ã [https://oreil.ly/yuVlX] ãšããŠç¥ãããŠãã)ã
çæ³ã ãšæã£ãããããã©ããããšæã£ããéã«ãããã£ãéšåãããµããå§ããã»ããã³ãçãå§ããã®ã§ã¯ãªããã
13.6.5ããã§ã€ã¯ãå©çšã§ããªãå Žåã¯ã©ããã¹ãã
APIã®ãªãŒããŒããã§ã€ã¯ã®äœæã«ä¹ãæ°ã§ãªãããã§ã€ã¯ã®äœæãã§ããªãå Žåã§ããèªåçšã®ãã§ã€ã¯ãæžãããããããªãããã®å®è¡ã®ããã«ããã®APIã®åŒã³åºãå šãŠãåäžã®ã¯ã©ã¹å ã«ã©ãããããããããã®APIã«éä¿¡ããªããã§ã€ã¯çã®ã¯ã©ã¹ãäœæãããšèšãæ¹æ³ãããã
å€éšAPIãšã®ã€ã³ã¿ãŒãã§ãŒã¹ãšãªãã®ãããéšåã®ãããªã¯ã©ã¹ãå¥éçšæããŠãããšããããšã ãšæããäœããã¿ãŒã³åããã£ããããªæ°ããããå¿ãããçæAIã«èãããšããããã¢ããã¿ãŒïŒAdapterïŒãã¿ãŒã³ããè¿ããã ã£ãã
13.7ãã¹ã¿ãã³ã°
ã¹ã¿ãã³ã°ã¯ããã¹ãå ã®æ¬ç©ã®å®è£ ã眮ãæããããã®æã£åãæ©ãç°¡åãªæ段ã§ããããšãå€ãã
ãã¹ã察象ã®å éšã®è©³çŽ°ãç¥ããªããšã§ããªãã®ã§ãããŸãè¯ããªããšããããšã«ã€ãªããã
13.7.1ãã¹ã¿ãã³ã°ã䜿ããããããšã«ããå±éº
ããããã¹ã¿ãã³ã°ã䜿ãããããšããã®ãããªãã¹ããä¿å®ããå¿ èŠã®ãããšã³ãžãã¢ã®çç£æ§ã倧ããæãããæããããã
çç£æ§ãæãããã®ã¯ãã¹ããæžããŠããæã§ããªããä¿å®ã®æ®µéããã£ãšèšãã°ãããããã¹ãã倱æããæã§ãããš(æã)ããã®ããã€ã³ãã
13.7.1.1ããã¹ããäžæ確ã«ãªã
ã¹ã¿ãã³ã°ã®ããã«ã¯ãã¹ã¿ãåãããé¢æ°ã®æåãå®çŸ©ããããã«ãäœåãªã³ãŒããæžãå¿ èŠãããã
ããã§äžæ確ã«ãªãã
13.7.1.2ããã¹ããèããªã
ã¹ã¿ãã³ã°ã¯ãã³ãŒãã®å®è£ 詳现ããã¹ãå ã«æŒæŽ©ããã
å人çã«ã¯ããã1çªåé¡ã ãšæãã
13.7.1.3ããã¹ãã®å¹æãèœã¡ã
ã¹ã¿ãã³ã°ã®å Žåãã¹ã¿ãåãããé¢æ°ãæ¬ç©ã®å®è£ ã®ããã«æ¯ãèãããšãä¿èšŒãããæç«ãŠã¯ååšããªãã âŠç¥âŠ ããã«ã¹ã¿ãã³ã°ã®å Žåãç¶æ ãä¿åããã®ã¯äžå¯èœã§ããã®ããã«ã³ãŒãã®ç¹å®ã®é¢ããã¹ãããã®ãå°é£ã«ãªãåŸãã
äŸãšããŠãæããããŠããããã¹ã¿ãã³ã°ã§ã¯ããŒã¿ããŒã¹ã«ä¿åãã§ããªãã®ã§ããã¹ã察象å®è¡åŸã«ããŒã¿ããŒã¹ã«ä¿åãããŠããã¯ãã®å€ãåãåºããŠæ€èšŒãããšããäºã¯ç¡çã
13.7.1.4ãã¹ã¿ãã³ã°ã䜿ããããŠããäŸ
ãã¹ããçããªãããã®å®è£ 詳现 (ãã©ã³ã¶ã¯ã·ã§ã³ããã»ããµãŒãã©ã®ããã«å©çšãããŠãããç) ããã¹ãå ã§å ¬éãããŠãªãæ§åã«æ³šç®ããŠã»ããã
ãã®æç« ã®åã«é§ç®ãªäŸãããããã®æç« ã®åŸã«è¯ãäŸããããé§ç®ãªå Žåã ãšã³ãŒããé·ããšããäºãšãå®è£ 詳现ã«èžã¿èŸŒã¿ãããšããããšãé§ç®ã ãšç€ºåããŠããã
13.7.2ãã¹ã¿ãã³ã°ãé©åãªã®ã¯ã©ããªå Žåã
æ¬ç©ã®å®è£ ã®å æ¬çãªçœ®æã§ã¯ãªãã¹ã¿ãã³ã°ãé©åãªã®ã¯ããã¹ã察象ã·ã¹ãã ããã©ã³ã¶ã¯ã·ã§ã³ã®ç©ºã§ãªããªã¹ããè¿ãããšãèŠæ±ããäŸ13-12ã®ããã«ããã¹ã察象ã·ã¹ãã ãããç¶æ ã«é·ç§»ãããããã«é¢æ°ãç¹å®ã®å€ãè¿ããªããã°ãªããªãå Žåã§ããã
ããã¹ã察象ã·ã¹ãã ãããç¶æ ã«é·ç§»ãããããã«é¢æ°ãç¹å®ã®å€ãè¿ããªããã°ãªããªãå Žåãããã€ã念é ã«çœ®ããŠãããªããšã綻ã³ãããªã®ã§æ³šæã
13.8ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã
ãããããã¹ããæçšã§ãèªã¿ããããå€åã«å¯ŸããŠåŒ·éãªç¶æ ã«ä¿ã€ã«ã¯ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã¯å¿ èŠãªå Žåã®ã¿å®æœããããšã倧åã ã
ä»ãŸã§ã®ç©ããããã£ãšäœ¿ããªãããã«ãã¹ãããšèšã£ãŠããã
13.8.1ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãããã¹ããŒããã¹ããåªå ãã
ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããšã¯ãå¯Ÿç §çãªãã®ãšããŠãã¹ããŒããã¹ã (https://oreil.ly/k3hSR) ãéããŠè¡åãã¹ãããæ¹ã奜ãŸããã âŠç¥âŠ Googleã§ã¯ãã¹ããŒããã¹ãã«éç¹ã眮ãæ¹ãããã¹ã±ãŒã©ãã«ã§ããããšãããã£ãŠãããã¹ããŒããã¹ãã¯ããã¹ãã®èããæžå°ãããã³ãŒãã®å€æŽãšä¿å®ãé·æçã«ã¯å®¹æã«ãªãã ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã®äžçªã®åé¡ã¯ããã¹ã察象ã·ã¹ãã ãæ£åžžã«åäœããŠããããšãç¥ãããããšãã§ããªãããšã ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããæ€èšŒã§ããã®ã¯ããé¢æ°ãæåŸ éãã«åŒã°ããŠããç¹ã ãã§ããã
ã¹ããŒããã¹ãã¯ãåã®æ¬ãä»ãŸã§ã®ãã®æ¬ã®å 容åºãŠãããããªè¯ããã¹ãã§äœ¿ãããŠããå 容ã®ããšãšæãã°è¯ãããã
13.8.2ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããé©åãªã®ã¯ã©ããªå Žåã
æ¬ç©ã®å®è£ ãŸãã¯ãã§ã€ã¯ã䜿ããªããããã¹ããŒããã¹ããå®æœã§ããªãå Žå(äŸãã°æ¬ç©ã®å®è£ ãé ããããããã§ã€ã¯ãååšããªãå Žå)ã
ä»æ¹ãªãã«äœ¿ããã¿ãŒã³ã
é¢æ°ãžã®åŒã³åºãã®åæ°ããŸãã¯é åºã®éããæãŸãããªãæåãåŒãèµ·ãããããããªãããã®æåãã¹ããŒããã¹ãã§æ€èšŒããã®ã¯é£ããããšããããããããããå Žåãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããæçšã ã
ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã§ã§ããããšãã€ãŸãé¢æ°ãã©ã®ããã«åŒã°ããããæ€èšŒããªããã°ãªããªããšãã«äœ¿ãããŸãã«æ¬æ¥ã®ç®çã®ããã®äœ¿ãæ¹ã
ãŠããããã¹ãå ã§ã¹ããŒããã¹ããå®æœã§ããªããªããã¹ã¿ãŒããã¹ããå®æœããããã«åºç¯å²ãªãã¹ããçšããŠãã¹ãã¹ã€ãŒããè£ãããšãç©æ¥µçã«æ€èšãã¹ãã ã
ã€ãŸãããŠããããã¹ãã§æ¬ç©ã®å®è£ ããã§ã€ã¯ãã¹ã¿ãã³ã°ã䜿ããªããªããã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããæ€èšãããã®ã§ã¯ãªããããã«ãã®åã«ã€ã³ãã°ã¬ãŒã·ã§ã³ãã¹ããè¿œå ããã»ãããŸã ãã·ã ãšããããšã ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã®åªå 床ã¯ããã»ã©ãŸã§ã«äœãã
13.8.3ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã®ãã¹ããã©ã¯ãã£ã¹
13.8.3.1ãç¶æ å€æŽåé¢æ°åãã®å Žåã®ã¿ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã®å®æœãéžã¹
ãã¹ã察象ã·ã¹ãã ã®å€ã®äžçãžã®å¯äœçšãããé¢æ°ãäŸ : sendEmail()ã saveRecord()ã logAccess()
以äžãç¶æ å€æŽåé¢æ°ã
éç¶æ å€æŽåã®é¢æ°ã«åããŠã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããå®æœãããšãçžäºäœçšã®ãã¿ãŒã³ãå€åãããšãã¯åžžã«ãã¹ããæŽæ°ããªããã°ãªããªããªãã®ã§ããã¹ããèããªãã
ãŽããšããªãããã
13.8.3.2ãéå°ãªæå®ã¯é¿ãã
ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããå®æœããå Žåããåãååã®é©çšãç®æãã¹ãã§ãããããã«ã¯ãã©ã®é¢æ°ãšåŒæ°ãæ€èšŒããããã«ã€ããŠéå°ãªæå®ãé¿ããã¹ãã ã
ååãšããã®ã¯ã12ç« ã®ã1ã€ã®ãã¹ãã§1ã€ã®æåã®æ€èšŒãè©Šã¿ããã ã
13.9ãçµè«
ãã¹ãããã«ã¯ãã³ãŒãã®å æ¬çãªãã¹ããæ¯æŽã§ãããŸããã¹ããé«éã«å®è¡ãããããšãæ ä¿ã§ããã®ã§ããšã³ãžãã¢ãªã³ã°é床ã«ãšã£ãŠæ±ºå®çã«éèŠã§ãããä»æ¹ã§ããã¹ãããã«ã®èª€çšã¯ããã¹ããäžæ確ã§ãèããå¹æã®äœããã®ã«ããããšããããããçç£æ§ã倧éã«æ¶èãããããªãã
ãã¹ãããã«ã¯è«žåã®å£ã
13.10ãèŠçŽ
- ãã¹ãããã«ããæ¬ç©ã®å®è£ ãåªå ãããã¹ãã§ããã
- ãã¹ãå ã§æ¬ç©ã®å®è£ ãå©çšã§ããªããªãããã§ã€ã¯ãçæ³çãªè§£æ³ã§ããå Žåãå€ãã
- ã¹ã¿ãã³ã°ã䜿ãããããšãäžæ確ã§èããã¹ãã«ã€ãªããã
- ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãã¯ã§ããã ãé¿ããã¹ãã§ããããã¹ã察象ã·ã¹ãã ã®å®è£ 詳现ãå ¬éãããããèããã¹ãã«ã€ãªããããã ã
è¯ããŸãšããå人çã«ã¯ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ããã¹ã¿ãã³ã°ãå®è£ ã®è©³çŽ°ãå ¬éããããšã«ã€ãªããããã«æãã®ã§é¿ããã¹ãã
ãããã«ã13ç« ãèªãã§ã
èªãã§å°è±¡çãªç®æã«äžç·ãåŒãã®ã¯ã1æ10æ¥(é)çµãã£ãã2024幎å ã«èªã¿çµãããããããšãæã£ããããã¯ãä»ã®ç掻ã¹ã¿ã€ã«ãããããã¯ãªããªãã£ãã
æ¬ç« ã®éµã¯ããã¹ãããã«ã«ã¯ïŒçš®é¡ã®äœ¿ãæ¹ããã§ã€ãã³ã°ãã¹ã¿ãã³ã°ãã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ãããããããããã®å®çŸ©ããŸãæŒãããããšã ãšæã£ãã3çš®é¡ãªãã ã£ãããšãªããã¡ã§äœåºŠãæ¯ãè¿ãå¿ èŠããããã©ããéžã¶ãã®åªå é äœã¯ãããããããã®ã§æãåºãããšãã«ã¡ãã£ãšæ¯ãè¿ããããã§ç¢ºä¿¡ãæãŠããšæãã
- ãã§ã€ãã³ã°: å®è£ ãäœéã§ãã£ãããçšæãé£ããå Žåã«ãã§ã€ãã³ã°ã䜿ããã¢ããã³ã°ãã¬ãŒã ã¯ãŒã¯ã䜿ã£ãŠããªããŠãããã§ã€ã¯çšã®ã¯ã©ã¹ãå¥éçšæããŠããã°å®çŸã§ããã
- ã¹ã¿ãã³ã°: ãããã®é¢æ°ãåŒã°ããããããããå€ãè¿ããŠãããã£ãŠãã奎ãã¹ã¿ãã³ã°ã
- ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã: é¢æ°ã®åŒã³åºãããããæ¹ã®æ€èšŒ ( = ã€ã³ã¿ã©ã¯ã·ã§ã³ãã¹ã) ã§ãã£ãŠãåŒã³åºãããåŸã®çµæã代æ¿ãããã® ( = ã¹ã¿ãã³ã°) ã§ã¯ãªã
äžç·ãåŒããç®æã«ã³ã¡ã³ãæžããŠããããšã§ç解ãæ·±ããããšããå匷ã¯ã1æ12æ¥(æ¥)çµãã£ããããã§ãã®ç« ã¯ãããŸããåŒãç¶ããã¹ããæ±ã£ãŠãã14ç« ãžé²ãã€ããã