ããããåãMartin FowlerããŠããããã¹ãïŒ blikiïŒUnitTest ïŒã®å®çŸ©ãè©Šã¿ãæ°æ¥åã«ããã®ç¿»èš³ã以äžã«ç€ºããŸãã ãããŠç¿»èš³åŸããã®äž»é¡ã«ã€ããŠã®ç§ã®èããããã€ããããŸãã
-
ãœãããŠã§ã¢éçºã®äžçã§ã¯ã圌ãã¯ãŠããããã¹ãã«ã€ããŠãã話ããŸããç§ã¯ããã°ã©ããŒãšããŠã®ãã£ãªã¢ãéããŠãã®æŠå¿µã«ç²ŸéããŠããŸãã ãããããœãããŠã§ã¢éçºã®äžçã®ä»ã®å€ãã®çšèªãšåæ§ã«ããã®çšèªã¯éåžžã«äžååã«å®çŸ©ãããŠãããéçºè ãå®éãããå³å¯ãªå®çŸ©ãæã£ãŠãããšèãããšæ··ä¹±ããããšããããããŸãã
ãŠããããã¹ããé »ç¹ã«äœ¿çšããŠããŸããããæçµçãªã³ãããã¡ã³ãã¯ãKent Beckãšãã¹ãããŒã«ã®xUnitãã¡ããªã®äœ¿çšãéå§ãããšãã«å§ãŸããŸããã ïŒæã ããxunitãã¹ãããšããçšèªããã®ã¿ã€ãã®ãã¹ãã«ããé©ããŠããããã«ããæããŸããïŒãŠããããã¹ãã¯ã ãšã¯ã¹ããªãŒã ããã°ã©ãã³ã° ïŒXPïŒã§ãéèŠãªã¢ã¯ãã£ããã£ã«ãªãã ãã¹ããéããŠè¿ éã«éçºãããŸãã ïŒTDD-ãã¹ãé§åéçºïŒã
XPã§ã®æåããã®åäœãã¹ãã®åœ¹å²ã¯ãããã€ãã®æžå¿µãåŒãèµ·ãããŸããã usenetã°ã«ãŒãã§ã®ãã¹ãã®å°é家ããããŠããããã¹ãããšããçšèªã®èª€çšã§XPã®æ¯æè ãscã£ãè°è«ãã¯ã£ãããšèŠããŠããŸãã ç§ãã¡ã¯åœŒã®å®çŸ©ãæ±ããŸãããã圌ã¯æ¬¡ã®ããã«çããŸããããç§ã®ãã¹ãã³ãŒã¹ã®æåã«ããŠããããã¹ãã®24ã®ç°ãªãå®çŸ©ãæ€èšããŸããã
æèŠã®çžéã«ãããããããããã€ãã®åŽé¢ã§ç§ãã¡ã®èŠç¹ã¯åæããŸããã 第äžã«ãåäœãã¹ãã¯äœã¬ãã«ã§ããããœãããŠã§ã¢ã·ã¹ãã ã®ããäžéšã®ã¿ã«çŠç¹ãåããããšããèãæ¹ããããŸãã 第äºã«ãä»æ¥ã®åäœãã¹ãã¯éåžžââãéçºè ãéåžžã®ããŒã«ã䜿çšããŠäœæãããããã«ãã¹ããã¬ãŒã ã¯ãŒã¯ïŒ*ïŒãè¿œå ãããŸãã 第äžã«ãåäœãã¹ãã¯ä»ã®ã¿ã€ãã®ãã¹ããããå€§å¹ ã«é«éã«ãªããšäºæ³ãããŸãã
ããããèŠè§£ã«ã¯éãããããŸããã ã¢ãžã¥ãŒã«ãšèãããããã®ã«ã¯ç°ãªãèŠç¹ããããŸã ã ãªããžã§ã¯ãæåèšèšã§ã¯ãã¢ãžã¥ãŒã«ã¯ã¯ã©ã¹ãšèŠãªãããŸã;æç¶ãçããã³æ©èœçãªã¢ãããŒãã§ã¯ãé¢æ°ã¯ã¢ãžã¥ãŒã«ãšèŠãªãããŸãã å®éãããã¯ç¶æ³ã«å¿ããæŠå¿µã§ããããŒã ã¯ãã·ã¹ãã ãç解ããããã¹ããããããããã®ã¢ãžã¥ãŒã«ãšããŠèæ ®ãã¹ããã®ã決å®ããŸãã ãŸããã¯ã©ã¹ã¯ã¢ãžã¥ãŒã«ã§ãããšããèãããå§ããŸãããããå¯æ¥ã«é¢é£ããã¯ã©ã¹ã®ã»ãããåäžã®ã¢ãžã¥ãŒã«ãšèŠãªãå§ããŸãã ããŸãäžè¬çã§ã¯ãããŸããããã¯ã©ã¹ã¡ãœããã®ãµãã»ãããã¢ãžã¥ãŒã«ãšèŠãªãããšãã§ããŸãã å®éããã®æŠå¿µãã©ã®ããã«å®çŸ©ãããã¯éèŠã§ã¯ãããŸããã
åé¢
ã¢ãããŒãã®ããéèŠãªéãã¯ããã¹ãäžã®ã¢ãžã¥ãŒã«ãçžäºäœçšãããªããžã§ã¯ãããåé¢ããå¿ èŠããããšãã質åã§ãã 泚æã¯ã©ã¹ã®äŸ¡æ Œèšç®æ¹æ³ããã¹ãããŠãããšããŸãã äŸ¡æ Œèšå®ã¡ãœããã¯ã補åããã³é¡§å®¢ã¯ã©ã¹ã®ããã€ãã®ã¡ãœãããåŒã³åºããŸãã çžäºäœçšãããªããžã§ã¯ãã®åé¢ã®ååã«åŸãå Žåã顧客ã®ã¯ã©ã¹ã®ãšã©ãŒã¯æ³šæã®ã¯ã©ã¹ã®ãã¹ãã®äœäžã«ã€ãªãããããããã§ã¯å®éã®è£œåãšé¡§å®¢ã®ã¯ã©ã¹ã䜿çšããããªãã§ãããã 代ããã«ãçžäºäœçšãããã¹ãŠã®ãªããžã§ã¯ãã«ãã¹ãããã«ã䜿çšããŸãã
ãããããã¹ãŠã®éçºè ãåé¢ã䜿çšããããã§ã¯ãããŸããã å®éã90幎代ã«xunitãã¹ããéå§ããããšããä»ã®ãªããžã§ã¯ããšã®éä¿¡ãéåžžã«äžäŸ¿ã§ãªãéãïŒãªã¢ãŒãã¯ã¬ãžããã«ãŒãæ€èšŒã·ã¹ãã ãšã®ããåããªã©ïŒããã¹ããããã¯ã©ã¹ãåé¢ããããšããŸããã§ããã é£æ¥ãããã¹ãã倱æããå Žåã§ãã倱æã®æ¬åœã®åå ãç解ããã®ã«å°é£ã¯ãããŸããã§ããã ãããã£ãŠãå®çšçãªèŠ³ç¹ãããå€ç«ã®æ¬ åŠãåé¡ãšã¯èããŸããã§ããã
圌ã®æ¹å€ã®çç±ã¯ããŸãã«ããŠããããã¹ããã®å®çŸ©ã«ãããå€ç«æ§ã®æ¬ åŠã§ãããã åäžã¢ãžã¥ãŒã«ã®åäœããã¹ããããããããŠããããã¹ããã®å®çŸ©ãé©åã ãšæããŸãã ãã®ã¢ãžã¥ãŒã«ä»¥å€ã®ãã¹ãŠãæ£åžžã«åäœããããšãåæã«ããã¹ããäœæããŠããŸãã
2000幎代ã«hunitãã¹ãã人æ°ãåãå§ãããšããå°ãªããšãäžéšã®äººã ã«ãšã£ãŠãå€ç«ã®æŠå¿µã¯åã³æŽ»æ°ãåãæ»ããŸããã ã¢ãã¯ããµããŒãããã¢ãã¯ãªããžã§ã¯ããšãã¬ãŒã ã¯ãŒã¯ã®åºçŸãèŠãŠããŸããã ãã®çµæãxunitãã¹ã¿ãŒã®åŠæ ¡ã2ã€ãããããããå€å žæŽŸãšæš¡æ¬åŠæŽŸãšåŒã³ãŸã ã Moqistsã®ããã«ãå€å žæŽŸã®ä¿¡å¥è ã¯å€ç«ãæ°ã«ããŸããã ç§ã¯äž¡æ¹ã®åŠæ ¡ã®hunitãã¹ã¿ãŒãç¥ã£ãŠãããå°æ¬ããŠããŸãïŒãã ããç§ã¯èªåã§å€å žæŽŸã«æå±ããŠããŸãïŒã
è€éãªçžäºäœçšã®ååšäžã§ãå€å žæŽŸã®ä»£è¡šè ïŒç§ãå«ãïŒã§ãããåœç©ã䜿çšããŸãïŒãã¹ãããã«ïŒã åœç©ã¯ããªã¢ãŒããµãŒãã¹ãæäœãããšãã®åäœã®äžç¢ºå®æ§ãæé€ããããã«éåžžã«è²Žéã§ãã å€å žæŽŸã®äžéšã®ä»£è¡šè ã¯ãããŒã¿ããŒã¹ããã¡ã€ã«ã·ã¹ãã ãªã©ã®å€éšãªãœãŒã¹ãšã®ããåãã«ã¯åœç©ã䜿çšããå¿ èŠããããšèããŠããŸãã äžéšã¯ãã®æèŠã¯äžç¢ºå®ãªè¡åã®ãªã¹ã¯ãäžéšã¯é床ã®åé¡ã«åºã¥ããŠããŸãã ããã¯æçšãªæšå¥šäºé ã ãšæããŸããã絶察çãªã«ãŒã«ãšã¯æããŸããã ãªãœãŒã¹ãžã®ã¢ã¯ã»ã¹ãå®å®ããŠãããååã«é«éã§ããã°ãåäœãã¹ããã䜿çšã§ããªãçç±ã¯ãããŸããã
ã¹ããŒã
åäœãã¹ãã«ã¯ãããã€ãã®å ±éã®ããããã£ããããŸããå°ããªã¹ã³ãŒããéçºè ã«ãã£ãŠäœæãããè¿ éã«å®è¡ãããŸããããã«ãããéçºäžã«é »ç¹ã«å®è¡ã§ããŸãã å®éãããã¯ã»ã«ããã¹ãã³ãŒãã®éèŠãªæ©èœã®1ã€ã§ãã ãã®å Žåãããã°ã©ããŒã¯ã³ãŒãã®å€æŽåŸã«ãŠããããã¹ããå®è¡ã§ããŸãã ã³ãŒããã³ã³ãã€ã«ããå¿ èŠããããã³ã«ããŠããããã¹ãã1åéã«æ°åå®è¡ã§ããŸãã ããã¯ã誀ã£ãŠäœããå£ããŠããŸã£ãå Žåãããã«ç¥ãããã®ã§äŸ¿å©ã§ãã ææ°ã®å€æŽã§äœããå£ããå Žåããã®ãšã©ãŒãããã«èŠã€ããæ¹ãã¯ããã«ç°¡åã§ãã
翻蚳è ã® ã¡ã¢
Kent Beckã¯ãã³ã³ãã€ã«äžã«ïŒå Žåã«ãã£ãŠã¯ãã¹ããªãã§ïŒãã¹ããå®è¡ãããšããã¢ã€ãã¢ãéçºããé£ç¶ãã¹ãïŒContinuous TestingïŒã®ã¢ã€ãã¢ãææ¡ããŸããã ãã®ãããªããŒã«ã®äŸïŒ Mighty-Mooseããã³NCrunch for .NETã JUnit Max for Javaã
ãã¹ããé »ç¹ã«å®è¡ããå Žåããã¹ãŠãå®è¡ããããšã¯ã§ããŸããã éåžžãçŸåšäœæ¥äžã®ã³ãŒãã§åäœãããã¹ãã®ã¿ãå®è¡ããå¿ èŠããããŸãã ãã®å Žåããã¹ãã®å®è¡æéã®ããã«ããã¹ãã®æ·±ããç ç²ã«ããŸãã ãã®ãã¹ãã¹ã€ãŒãããã³ã³ãã€ã«ã¹ã€ãŒãããšåŒã³ãŸããããã¯ãRubyã®ãããªã€ã³ã¿ãŒããªã¿èšèªã§ããã³ã³ãã€ã«ãããã³ã«å®è¡ããããã§ãã
ç¶ç¶çã€ã³ãã°ã¬ãŒã·ã§ã³ã䜿çšããå Žåãã¹ãããã®1ã€ãšããŠãã¹ããå®è¡ããå¿ èŠããããŸãã ç§ãã³ãããã¹ã€ãŒããšåŒã¶ãã®ãã¹ãã¹ã€ãŒãã«ã¯ããã¹ãŠã®åäœãã¹ããå«ãŸããŠããå¿ èŠããããŸãã ãŸããããã€ãã®åãå ¥ããã¹ãïŒ Broad-Stackãã¹ããŸãã¯End-to-Endãã¹ã ïŒãå«ãŸããããšããããŸãã éçºè ãšããŠããã®ãã¹ãã¹ã€ãŒãã1æ¥ã«æ°åå®è¡ããå¿ èŠããããŸãããã¡ãããããŒãžã§ã³ç®¡çã·ã¹ãã ãžã®å€æŽãã³ãããããåã«ããŸããã®ãããªæ©äŒãããã°ãäŒæ©äžãŸãã¯éäŒäžã«å®è¡ããå¿ èŠããããŸãã äžé£ã®ã³ããããã¹ããéãå®è¡ãããã»ã©ãå®è¡ã§ããé »åºŠãé«ããªããŸãïŒ**ïŒã
ãŠããããã¹ããšãã®ã»ããã®å®è¡é床ã«ã€ããŠã¯ã人ã«ãã£ãŠåºæºãç°ãªããŸãã ãããã£ãŠã David Heinemeier Hanssonã«ãšã£ãŠã¯ãã³ã³ãã€ã«ã¹ã€ãŒããæ°ç§éå®è¡ã ãã³ãããã¹ã€ãŒããæ°åéå®è¡ããã ãã§ååã§ãã Gary Bernhardtã¯ãããé ããããšèŠãªããã³ã³ãã€ã«ã»ãããçŽ300ããªç§å®è¡ããããšäž»åŒµãã Dan Bodartã¯ã³ãããã»ãããæ°ç§ä»¥äžå®äºããã®ãåŸ ã¡ãããããŸããã
ãã®è³ªåã«å¯Ÿããå¯äžã®æ£ããçãããããšã¯æããŸããã å人çã«ã¯ãã³ã³ãã€ã«ã»ããã1ç§ãŸãã¯2ã3ç§ã§å®è¡ããããšãã«éãã¯èŠãããŸããã§ããã ç§ã¯ãã³ãããã»ããã10å以äžå®è¡ããªããšããKent Beckã®èŠåãæ°ã«å ¥ã£ãŠããŸãã ããã§ã®äž»ãªã¢ã€ãã¢ã¯ããã¹ãã¹ã€ãŒããååãªé »åºŠã§å®è¡ããããšã劚ããªãããã«ããã¹ãã¹ã€ãŒããååã«é«éã§å®è¡ããããšã§ãã ãŸãããååãªããšã¯ããã¹ãã§ãã°ãèŠã€ãã£ããšãã«ãå°éã®ã³ãŒããæãåœãŠãŠãããªãè¿ éã«èŠã€ããå¿ èŠãããããšãæå³ããŸãã
泚é
ïŒ*ïŒç§ã¯ãä»æ¥ããšèšããŸããããã¯XPã®ãããã§æ£ç¢ºã«å€ãã£ãããã§ãã æ°äžçŽã®å§ãŸãããããè°è«ã®äžã§ãXPã®æ¯æè ã¯ãäžè¬çã«åãå ¥ããããŠãã芳ç¹ã¯ããã°ã©ããèªåã®ã³ãŒãããã¹ãããã¹ãã§ã¯ãªããšããããšã§ãããããéåžžã«æ¹å€ãããŠããŸããã äžéšã®äŒæ¥ã§ã¯ãéçºè ã³ãŒãã®åäœãã¹ããäœæããããšãå¯äžã®ã¿ã¹ã¯ã§ããå°éã®åäœãã¹ã¿ãŒãããŸããã ãã®èŠ³ç¹ã®çç±ã¯æ¬¡ã®ãšããã§ãã人ã ã¯ã³ãŒãããã¹ããããšãã«ãæŠå¿µçãªç²ç®ããæã£ãŠããŸãã ããã°ã©ããŒã¯è²§åŒ±ãªãã¹ã¿ãŒãªã®ã§ãããã°ã©ããŒãšãã¹ã¿ãŒã®éã«äœããã®åœ¢ã§å¯Ÿç«ããããšã¯æçšã§ãã XPãµããŒã¿ãŒã®èŠ³ç¹ã¯ãããã°ã©ããŒãå°ãªããšãåå¥ã®ãã¢ãžã¥ãŒã«ãã®ã¬ãã«ã§åªç§ãªãã¹ã¿ãŒã«ââãªãããšãåŠã¶ããšãã§ãããã¹ããäœæããããã«è¿œå ã®ã°ã«ãŒããé¢äžããããšããã¹ãã«ãã£ãŠæäŸããããã£ãŒãããã¯ãéåžžã«é ããªããšããããšã§ããã XUnitããŒã«ã¯ããã¹ãäœæã®ãªãŒããŒããããæå°éã«æããããã«ç¹å¥ã«éçºãããããããã®ç¹ã§éåžžã«éèŠãªåœ¹å²ãæãããŸããã
ïŒ**ïŒå®è¡æéãã³ããããã¹ãã®æéãããé·ãæçšãªãã¹ããããå Žåã å±éãã€ãã©ã€ã³ãæ§ç¯ãããããã®ãã¹ãããã€ãã©ã€ã³ã®åŸåã®ã¹ããŒãžã«é 眮ããå¿ èŠããããŸãã
-
ãã®èšäºã§ã¯ãããŒãã£ã³ã¯ã³ãŒããšãã¹ãã®äœæã®åé¡ã«æå³çã«å¯ŸåŠããã代ããã«åäœãã¹ãã®å®çŸ©ãæäŸããã¢ãžã¥ãŒã«ã®æŠå¿µã«é¢ããããŸããŸãªèŠç¹ã®ååšããåé¢ãšå®è¡ã®é床ã®å¿ èŠæ§ã«ã€ããŠç€ºããããšããŸãã
ç§èªèº«ã¯ããŠããããã¹ããä»ã®äžçããå®å šã«éé¢ãããã¯ã©ã¹ããã¹ãããã¹ãã ãšããæèŠã«åºããããŸããã ããšãã°ããããŒãã»ããŒãã£ã³ãèæžãPrinciplesãPatternsãand Agile Development Techniquesãã§èª¬æããŠããã®ã¯ãã®ã¢ãããŒãã§ããããäŸåé¢ä¿é転ã®åçã«é¢ããæ¹å€çãªèŠæ¹ããšããèšäºã§ãããæ¹å€ããŸããã
ç§ã®ç解ã§ã¯ãåäœã決å®è«çã§é«éã§ããã°ãåäœãã¹ãã§ç¹å®ã®ã¯ã©ã¹ã䜿çšããŠããŸã£ããåé¡ã¯ãããŸããã äžèŠãªäŸåé¢ä¿ã匷調ãããšãã¯ã©ã¹ã®ã«ãã»ã«åãæãªããããã®çµæãã·ã¹ãã ã®ç解ãšä¿å®ã容æã«ãªããŸããã å®å®ããäŸåé¢ä¿ã¯ãã¹ãŠçŽæ¥äœ¿çšã§ãã䜿çšããå¿ èŠããããŸãããŸããåäœã決å®çã§ã¯ãªããå¯å€ãäŸåé¢ä¿ã®ã¿ãåºå¥ããå¿ èŠããããŸãã
ç§ã¯ãŠããããã¹ãã®å€å žæŽŸã®ãµããŒã¿ãŒã§ãããé決å®çãªå€éšãªãœãŒã¹ã«ã¢ã¯ã»ã¹ããªãå Žåãå®éã®ã¯ã©ã¹ã䜿çšããå¿ èŠããããšæããŸãã ç§ã®ç解ã«ãããmokaã®è±å¯ãã®åé¡ã¯ãåãåã£ããã¹ãããã¹ãç°å¢ã«äŸåããããŠãã¹ãç°å¢ãè匱ã«ãªããã€ã³ã¿ãŒãã§ãŒã¹ãšéæ¥æ§ã®è±å¯ããã·ã¹ãã ã®ãç解ããããããæªåããã99ïŒ ã®ã±ãŒã¹ã§ã¯å¿ èŠãªãæè»æ§ãè¿œå ããããšã§ãã
ãã¡ãããmokaã®äœ¿çšã«é¢ããä»ã®èŠ³ç¹ããããŸãã ãããã£ãŠãã¹ãã£ãŒãã»ããªãŒãã³ãšãããã»ãã©ã€ã¹ã®èæžãGrowing Object-Oriented Software Guided by Testsãã§ã¯ ãå¥ã®èŠç¹ãåãããŠããŸãã ãã ããåæã«ããã¹ãã®ããŠã³ã¿ã€ã ã泚ææ·±ãç£èŠãããã¹ãã®åè¡ã«moqã®5è¡ã®åæåãæ¥ãç¶æ³ãèš±å¯ããŸããã
2ã€ã®ãã£ã³ãã®ããããã«åºå·ããããšã¯çµ¶å¯Ÿã«æ®éã§ãïŒã¯ã©ã·ãã¯ãŸãã¯ã¢ããã¹ãã äž»ãªãã®ã¯ãããªãã®éžæãæèçã§ãããããªãã®ãã¹ããéçºãšä¿å®ãç°¡çŽ åããããã劚ããªãããšã§ãã