ããªãã¯åçµãã¾ãã
@katzchangããã®æ¬¡ã¨ãªãTDD Advent Calendar jp: 2011ã®11æ¥ç®è¨äºã«ãªãã¾ãã
ç»é²è
ä¸è¦§ãçºãããã³ã«ãä»ã«å¦çãããªãâ¦ãã¨åãã¤ã¤ããã¼ãã«ãä¸ããç¶ããã¿ã¤ãã³ã°ã§ã®æ
å½åã¨ãããã§èã«ç©´ãããããã§ãã
11ææç¹ã§ã¯ãTDDBCã«ã¤ãã¦æ¸ãããã¨æã£ã¦ããã®ã§ããã12/1ã®ç´ æ´ãããè¨äºã«ãã£ã¦æ¸ããã¨ããªããªã£ãã*1ãæ¥ã
追å ããã¦ããç´ æµè¨äºãçºããªããã©ããªå
容ã«ãããæ©ãã çµæãé£ãæ°å³ãªãã®ã«ãªã£ã¦ãã¾ãã¾ããâ¦
ã¯ããã«
ã¨ããããããã®10æ¥éã«æ¸ãããTDD Advent Calendarè¨äºãæ¯ãè¿ã£ã¦ã¿ã¾ããããã¾ã èªãã§ãªãæ¹ã¯ãã¾ãã¯10æ¥ç®ã¾ã§ã®èªãã§ã¿ã¦ãã ããã
ã¾ããTDDå°å¹´ã®æ³ããå¦ã¶ã¹ãçç±ãç¥ããã¨ãã§ãã¾ããããã¦TDDãå¦ã¶åã«èº«ã«ä»ãã¦ããã¨ããã¨æãåºç¤ä½åãæ示ãããTDDå
¥éæ¹æ³ã®ï¼ã¤ãç´¹ä»ããã¦ãã¾ããã¾ããTDDãå¦ã¶ãã¨ã§å¾ãç¥èã¯ãã®ãããªç¾å ´ã§ãå½¹ã«ãã¤ãã¨ã示ããã¦ãã¾ãã
TDDç·´ç¿ãã§ã¼ãºã§ã¯ãä¾ãã°Perlã§ã®ç°å¢æ§ç¯æ¹æ³ãJavaã§ã®å®æ¼é¢¨æ¯ãJavaã®ãµã³ãã«ãè¦ã¦TDDã®ãªãºã ãç¥ããã¨ãã§ãã¾ããã¾ããTDDããéã®æå©ãã¨ãã¦ã®ã«ãã¬ãã¸ã«å¯¾ããèãæ¹ãèªåãåãå·»ã対象ãããã°ã©ãã³ã°å¯¾è±¡(ããã¦TDDç·´ç¿ã®å¯¾è±¡)ã«ã§ãããã¨ãèªã¿åãã¾ãã
TDDãç·´ç¿ãã¦ãããã¡ã«ä»²éãã»ãããªã£ããåºããããªã£ããTDDBCãéå¬ãã¦ã¿ãã®ãä¸ã¤ã®æ¹æ³ã§ãã
ãã¦ãæ¯ãè¿ããªããç§ã«ä½ãæ¸ããã®ããèãã¦ã¿ãã®ã§ãããç§ãæ¸ãããã¨ã¯TDDå
¥éã«é¢ãããã¨ããªã¨ãããã¨ã§ã@goyokiããã¨ãã¿è¢«ãã§ã¯ããã¾ããæ¸ãã¦ãããã¨æãã¾ãã
ããªãã¯ãåçµãã¾ããï¼
å¤ãã®æ¹ãå°ãªãã¨ãä¸åº¦ä»¥ä¸ã®åçµçµé¨ãããã¨æãã¾ãã
ã§ã¯ãåç»ã§åºã¦ããã³ã¼ããæ¸ãã¨ã£ãããGitHubãªã©ã§å
¬éããã¦ããã³ã¼ãããã°ã«ãããã£ã¦ãã¬ã¼ã¹*2ãããã¨ãããã¾ããï¼ãã¡ãã¯è¦ããã¾ãã¯èªãã ãã©æ¸ãã¾ã§ã¯â¦ã¨ããæãã§ããããã
Web+DB Pressé£åã®åç°ããã®åç»ã«ãããªãã¨ãæ¸ããã¦ãã¾ãã
åçµã§ã¯å¾ãããªãå ¸åçãªãã®ã®ä¸ã¤ããããªãºã ããªãã§ãããå®éã«æ¬ãæã§åãã¦ã¿ã¦ããã§ã¯Kent Beckã¯ã©ãããæè¦ã§ãã¹ããèµ·åãã¦ããã®ããç§ã¯ã©ãããæè¦ã§ãã¹ããèµ·åãã¦ããã®ãã¨ãããã¨ã¯ãä¼ããã¾ããã
動画で解説 和田卓人のテスト駆動開発講座 第7回
ã³ã¼ãã®æµããæ¬ã«æ¸ããã¨ã¯ã§ãã¦ãããªãºã ã¯æ¸ãã¾ãããTDDBCã®åå çç±ã¨ãã¦ãTDDã®ãªãºã ãç¥ãããããããã®ã¯ããããã£ãèæ¯ãé¢ä¿ãã¦ããã®ã ã¨æãã¾ãã
ãªãºã ãç¥ãããã身ã«ã¤ãããã¨ããæ¹ã«ã¾ããå§ãããã®ã¯TDDBCã§ããTDDBCã§ã¯å®éã«èªåã®æãåããã¾ãããçµé¨è
ããå©è¨ãããã ããããã¾ããã¾ããããããã®ç¢ºçã§èªåã®å¸æããè¨èªã§ã®TDDãªãºã ãç¥ããã¨ãã§ãã¾ãããããæ®å¿µãªãã¨ã«ãæ½é¸ã«æ¼ãããã©ã®éå¬å°ãé ãã¦åå ã§ããªããäºå®ããããã«ãªããªãåå ã§ããªãâ¦ãªã©ãæ§ã
ãªçç±ã§TDDBCã«åå ã§ããªãå¯è½æ§ãããã¾ãã
TDDBCã«åå ã§ããªãå ´åã§ããåç»ãè¦ã¦å¦ã¶ãã¨ãã§ãã¾ããTDDBCãé »ç¹ã«éå¬ãããããã«ãªãã¾ã§ã¯ãããããããã主æµã ã£ãã®ã§ã¯ãªãã§ãããããåç»ã¯éçºè
ã®éçºã¹ã¿ã¤ã«ãã»ã¼ãã®ã¾ã¾è¦è¦æ
å ±ã¨ãã¦è¦è´è
ã«ä¸ãã¦ããã¾ããããã¯ãã»ããã¼ãªã©ã§è¡ããã¦ãããã¢ã«ãåããã¨ãè¨ãã¾ãã
ããä¸ã¤æ¹æ³ããããGitHubãBitbucketã§å
¬éããã¦ããTDDBCæ¼ç¿ææããã¬ã¼ã¹ãåæããæ¹æ³ã§ããæ´å²æ¹å¤ãè¡ã£ã¦ããªãã³ããããã°ãè¦ãã°ãã³ãããæå»ããTDDãªãºã ãã³ãããã¡ãã»ã¼ã¸ãã½ã¼ã¹ã³ã¼ãããä½ãå®è£
ãããããããã®ã§ãããæ¹ãèããã°TDDã®ãªãºã *3ãç¥ãã身ã«ã¤ãããã¨ãå¯è½ã§ãããã ããã©ããªæä½ãè¡ã£ããªã©ã®æ
å ±ããªãã®ã¨ãããã¾ã§æå»ã¨ãããã¼ã¿æ
å ±ãªã®ã§ããªãºã ã身ã«ã¤ããããã®éå
·ã¨ãã¦ä½¿ãããã«ã¯ä¸å·¥å¤«å¿
è¦ã«ãªãã¾ããéã«ã¡ãªããã¯ããé¡ãå
¥éã¨ãã¦ã¡ããã©è¯ã大ããã§ãããã¨ãèªåã使ããè¨èªã®ãã¼ã¿ãå
¬éããã¦ããå¯è½æ§ããããã¨ã§ããç§ãæ¤ç´¢ããç¯å²ã§ã¯GitHubã¨Bitbucketã«ã¦Java/C++/Ruby/PHP/C#/Python/Groovy/Scala/OCaml(?)/JavaScript/F#ã®ãªãã¸ããªãçºè¦ã§ãã¾ããã
åçµãåç»ãè¦è´ããã°è§£æãã³ã¼ãã®ãã¬ã¼ã¹ã¯èª°ã§ãä¸äººã§ãã¾ããã¤ã¾ãTDDã¯ãå¦ã¶ã®ãé£ããã¨è¨ããã¦ã¯ãããã®ã®ãä¸äººã§å¦ã¹ãã¹ãã«ãªã®ã§ããç¹ã«ç¾å¨ã¯æ§ã
ãªæ
å ±ããã¼ã¿ãåºåã£ã¦ããã®ã§ãä¸æåã«æ¯ã¹ãã°æ ¼æ®µã«å¦ã³ãããç°å¢ã«ãªã£ã¦ããã¨æãã¾ãã
TDDBCæ¼ç¿ææããTDDããã»ã¹ãå¦ã¶
ãã¦ããããã¯ã誰å¾æå¼·ãã§ããTDDBCæ¼ç¿ææããTDDããã»ã¹ãå¦ã¶æ¹æ³ã«ã¤ãã¦æ¸ãã¾ãã
å
容ã¯ä»¥ä¸ã®ãããªé åºã«ãªãã¾ãã
- ã¾ãã¯ãã®ã¾ã¾æ¸ãåã
- ããããªãã£ããã¨ãç解ã§ããããã«ãªãã¾ã§èª¿ã¹ã
- ãé¡ã®ä»æ§ã¨ãã¹ããªã¹ã(TODOãªã¹ã)ãç·ã§çµã¶
- ãã¹ããªã¹ã(TODOãªã¹ã)ãå ¬éããã¦ããå ´å
- ãã¹ããªã¹ã(TODOãªã¹ã)ãå ¬éããã¦ããªãå ´å
- æéãã¯ãã
- éå ·ã磨ã
- (è°è«ãåçµãã)
åºæ¬çã«ã¯ç§ãç 究ã§ãã¼ã¿è§£æããã¨ãã«ãã£ãããããã¨ãçµã¿åããããã®ã§ãå
¨é¨ãããã¨ããã¨ããããæéãå¿
è¦ã«ãªãã¾ãã
ã¡ãªããã¨ãã¦ã¯
- è¨èªãã¨ã®TDDããã»ã¹ãå¦ã¹ã
- èªåã«è¶³ããªãç¥èãè£å¼·ã§ãã
- ãã¼ã«ã使ãç·´ç¿ã«ãªã
- å ´åã«ãã£ã¦ã¯ãTDDããªãã»ãããããããé¨åãç¥ããã¨ãã§ãã
ãã¡ãªããã¯ã¨ã«ããæéãããããã¨ã§ãã
ã¾ãã¯ãã®ã¾ã¾æ¸ãåã
ã³ããããããé åºã§ã³ã¼ããæ¸ãåãã¦ããã¾ãããã®éãããããªãããã¨ãè¦ã¤ããããããããªãã£ããã¨ãã¡ã¢ãã¦ãªã¹ãã¢ãããã¦ããã¾ããããã°ãªã©ã§è§£èª¬ãæ¸ããã¦ãããã¼ã¿ã®å ´åã¯è§£èª¬ã®é åºã«å¾ã£ã¦åãã¦ããã¾ããããã¾ãããã¼ã¸ã§ã³ç®¡çããã¦ããã¦ãã ããã
ããã§ã®ç®çã¯ãã©ã®é åºã§ãã¹ãã±ã¼ã¹ãé¸æãã¦ããããã©ã®ã¿ã¤ãã³ã°ã§ãªãã¡ã¯ã¿ãªã³ã°ãã¦ããããªã©ã®éçºã®æµããç¥ããã¨ã§ãã
ããããªãã£ããã¨ãç解ã§ããããã«ãªãã¾ã§èª¿ã¹ã
åã¹ãããã§ããããªãã£ããã¨ããªã¹ãåããã®ã§ããªã¹ãããããããªããã¨ããªããªãã¾ã§æéã®è¨±ãéã調ã¹ã¦ããã¾ãã調ã¹ããã¨ããã¼ã¸ã§ã³ç®¡çãã¾ãããã
ããããªããã¨ãããããªãã¾ã¾æ¬¡ã«é²ãã®ã¯å¾ã
è² åµã«ãªããããªãã®ã§ãããã§æ¸
ç®ãã¦ããã¾ãã
ãé¡ã®ä»æ§ã¨ãã¹ããªã¹ã(TODOãªã¹ã)ãç·ã§çµã¶
ããã¯éçºè
ãããã°ãªã©ã§ãã¹ããªã¹ããªã©ãå
¬éãã¦ããå ´åã¨ããã§ãªãå ´åã§å°ããããã¨ãç°ãªãã¾ãã
ãã¹ããªã¹ããTODOãªã¹ããå
¬éããã¦ããå ´åã¯ãä»æ§ã¨ãªã¹ããçºããªããé¢é£ããããªãã®ãç·ã§çµãã ãã解説ãæ¸ããã¦ããå ´åãªã©ã¯æ´ã«ãæµããæ³åããªããçåã«æã£ããã¨ãç¶æ³ãè¦æ±ãªã©ãæ¸ãè¾¼ã¿ã¤ãªããããã¦ããã¾ãããã¨ãã°bleis-tiftããã®TDDBCæ±äº¬1.6ã®ãã¼ã¿ãåºã«ãã£ã¦ã¿ãã¨ãæåã®ã»ãã¯ä»¥ä¸ã®ããã«ãªãã¾ããã
ããã§ã¯3,4è²ç¨åº¦ã®ãã¼ã«ãã³ããç®çã«ãããã¦è²ãå¤ããªãã使ã£ã¦ãã¾ããã¨ã«ããæ
å ±ãçåã«æã£ããã¨ãæ¸ãè¾¼ãã§ããã¾ãã
ãã¹ããªã¹ããªã©ããªãå ´åã¯ããã¹ãã±ã¼ã¹ãæå¾
å¤ãªã©ãããªã¹ããä½æããæ¸ãè¾¼ãã§ããã¾ãã
注æç¹ã¨ãã¦ã¯ãããã¾ã§ãã®ä½æ¥ã¯èªåã®æ³åã§æ¸ãã¦ããã¨ãããã¨ã§ããéçºè
ã¯åãèãã ã£ãããããã¾ããããå
¨ãéãèãã§ãªã¹ããä½æããããããã¾ãããçç¸ã¯èãã¦ã¿ãã¾ã§ããããªãã®ã§ãæ°ã«ãªã£ãå ´åã¯è³ªåãã¦ã¿ãã¨ããããããã¾ããã
ãã®ã¹ãããã§ã®ç®çã¯ãä»æ§ãã©ããã£ã¦ç´°åãã«ãã¦ããã®ããç¥ã£ãããèªåã§è©¦ãã«ç´°åãã«ããããããã¨ã§ãã
æéãã¯ãã
ãã¦ãããããã³ã¼ããæ¸ããã欲æ±ãã§ã¦ãã¦ããã¨æãã®ã§ãåã³ã³ã¼ããæ¸ãåãä½æ¥ã«æ»ãã¾ãããã ããæåã«è¡ã£ã"ã¨ããããæ¸ãåã"ããã§ã¯ããã¾ãããä½æ¥ã¯ä¸è¨ã®é åºã§è¡ã£ã¦ããã¾ãã
- ã³ããããã°ã®ã³ãããæå»ããã³ãããééãå°åºãã(ééã10åãè¶ ãããã®ã¯10åã«ãã)
- ã¿ã¤ãã¼ãç¨æãã(好ã¿ã®ãã®ããªããã°ãã¼ã«ãèªä½ãã¾ããã)
- ã¿ã¤ãã¼ã«ã³ãããééãå ¥åãã¹ã¿ã¼ããããã³ã¼ããæ¸ãåãã¯ããã
- ã¿ã¤ãã¼ããªãã¾ã§ã«æ¸ãåãçµãããªãã£ãã³ãããé¨åããã£ãããéã«åããªãã£ããã¨ãè¨é²ãã¦æ¸ãåããç¶ãã
ãã®ãã§ã¼ãºã§ã¯ãè¨é²ããã¦ãããã¼ã¿ã®TDDããã»ã¹ã¨èªåã®æ¸ãåãé度ã試ãã«æ¯è¼ãã¾ããTDDããã»ã¹ã¯æ©ãåããã°ããã¨ããããã§ã¯ãªãã§ãããè¨è¨å¤æãããªããå®è£
ãã¦ãããã¼ã¿ãããæããã«æ¸ãåãé度ãé
ãå ´åã¯ãèªåã使ã£ã¦ããéå
·ããã¾ãæ±ãã¦ããªãå¯è½æ§ãããã¾ãã次ã®ãã§ã¼ãºã§è¨ç·´ãã¾ãããã
ããã§ã®ç®çã¯éãã競ããã¨ã§ã¯ããã¾ãããããã¾ã§éå
·ããã¡ãã¨æ±ãã¦ãããã®ç¢ºèªã¨ãä»éçºè
ã®TDDã®ãªãºã ãç¥ããã¨ãç®çã¨ãªãã¾ãã
éå ·ã磨ã
ãã¼ã¿ãããæ¸ãåãä½æ¥ãé
ãã£ãã¨è¨ããã¨ã¯ãã¤ã¾ãã¨ãã£ã¿ãIDEã¨ãã£ãéå
·ã使ãããªãã¦ããªããã¨ãæå³ãã¾ããéå
·ã磨ããè
ã磨ããã¨ã§ã¹ã ã¼ãºã«ã³ã¼ãã£ã³ã°ã§ããããã«ãªãã¾ãããããã¨ãã°IDEã®ã·ã§ã¼ãã«ããã³ãã³ããè¦ããããã¨ãã£ã¿ãã«ã¹ã¿ãã¤ãºãã¦ããéçºããããç°å¢ã«ãã¦ããã®ã§ãã
ã¨ãã£ã¿ã®è¨å®ããã©ã°ã¤ã³ã«ä½ã使ãã°å¹çãããã®ãã§ããããªããã¨ãããã°ãä»ã®äººã«ç¸è«ãã¦ã¿ã¾ãããããã®äººã¯ä½ãè¯ãæ¹æ³ããã®ãç¥ã£ã¦ããããããã¾ããã
éå
·ããè
ã磨ããã¨ã§éçºå¹çããããã¾ããããã¦ããã¯TDDã«ãè¯ãå½±é¿ãä¸ããã®ã§ãããã§è¨ç·´ãã¦æ¹åãã¦ããã¾ãããã
ãã¦ãä¸ã¤ã®ãªãã¸ããªã«å¯¾ãã¦è¡ãä½æ¥ã®æµãã¯ä»¥ä¸ã«ãªãã¾ãã
æåã¯ãªããªãã®ã§ããªãæéããããã¨æããã¾ãããæ°ãããªãã¦ãããã¡ã«ããªãTDDã«æ
£ããã®ã§ãæ
£ãã¦ããããã®æ¹æ³ããé¢ãèªåã®ã¹ã¿ã¤ã«ã§TDDããã°ããã¨æãã¾ãã
(è°è«ãåçµãã)
TDDã¯ã§ããããã«ãªãã¾ãããã§ãããTDDãç¿å¾ã§ããã¨ãã¦èª°ãã«å©ç¹ãæ¬ ç¹ããã¡ãã¨èª¬æã§ããã§ããããï¼
ã§ããªãã¨æã£ãå ´åã¯è³æãã©ãã©ãèªã¿è¿ãã¾ããããããã«ãæéãããã°è¬æ¼ãªã©ãåçµãã¦ã¿ã¾ããããããªãæéã®ãããä½æ¥ã§ã¯ããã¾ãããåçµããããã«ä¸åä¸å¥éããèããã¨ã«ãªãã®ã§ã¨ã¦ãåå¼·ã«ãªãã¾ãã
ãã®ã¹ãããã¯ãªãã·ã§ã³é
ç®ã§ããèªåã®è¨èã§ãã§ã«èª¬æã§ãã人ã¯ãããªãã¨ããªãã¦ãããã§ãããè¬æ¼ã®åçµãªã©ã¯ã¨ã«ããæéã使ãã®ã§æéããªãã®ã§ããã°ãããªãã»ããç¡é£ã§ãã
ãããã«
é·ããªã£ã¦ãã¾ãã¾ããããçµå±ä½ãè¨ãããã£ãã®ãã¨ããã°ãTDDã¯ä¸äººã§ãå¦ã¹ããã¨ãããã¨ããã£ããTDDBCã®æ¼ç¿ææãå
¬éããã¦ããã®ã§åæããªããèªåã®TDDåä¸æã«å½¹ç«ã¦ã¦ã¿ã¦ã¯ãããã§ãããããã¨ãããã¨ã§ããã
次ã¯@irofããã®ãã¹ãã¨è¨ããã¼ããã¼ã§ãã
*1:TDD Advent Calendarã¯ãã¿è¢«ãOKã¨ãªã£ã¦ããã®ã§ããããã®è¨äºãè¦ãå¾ã§ã¯æ¸ããæ°ãããªããªãã¾ãã
*2:"ãã§ã«ããç©ããªãã"ã¨ããæå³ã§ã®ãã¬ã¼ã¹ã§ã
*3:ãã®å ´åã®TDDãªãºã ã¯ãæ£ç¢ºã«ã¯"DVCSæä½ãå«ããTDDãªãºã "ã§ã