Gradle ã§ã«ãã¬ãã¸ãè¨æ¸¬ãã¦ã¿ã ãã®ï¼
ãGradle でカバレッジを計測してみるãã«å¼ãç¶ã
EMMA ã¨ããããã¨ããã§ããã訳ãã£ã¦ Gradle ã§ã®ã«ãã¬ãã¸è¨æ¸¬ã«ã¯ Cobertura ã使ããã¨ã«ãã¾ããã
ã¨è¨ãã®ã Jenkins CI ã® EMMA ãã©ã°ã¤ã³ã¨ã¯ ãã¾ãç¸æ§ãè¯ããªãããã ããã§ãã
ãªã㨠Jenkins CI ã® EMMA ãã©ã°ã¤ã³ã ã¨ã«ãã¬ãã¸ã®éè¨ãã表示ãããªãã®ã§ã
Eclipse ã htmlå½¢å¼ã®ããã«ã½ã¼ã¹ä¸ã®ã©ã®ã³ã¼ããå®è¡ããã¦ããªãã®ãã¾ã§ã¯ç¢ºèªã§ããªãã®ã§ãã
EMMA ãã©ã°ã¤ã³ã®ä¸å ·åãã¨æã£ãã®ã§ãããå®ã¯ããããä»æ§ãããã EMMA ã®リファレンスãããèªãã§ã¿ãã Ant ã® report ã¿ã¹ã¯ã® sourcepath å±æ§ã®èª¬æã«
An optional source path to use for report generation (a path-like structure). It is interpreted as a list of directories (separated by the OS-specific classpath separator or comma) containing .java source files. The local path names within each directory should reflect class package names. (Currently, only the HTML report generator uses this data, and only at method report depth.)ã¨æ¸ãã¦ãããã©ããã sourcepath 㯠html å½¢å¼ã§ããå©ç¨ãããªããããã
ãã¡ãããJenkins CI ã§ã¯ xml å½¢å¼ã§åºåããããã¡ã¤ã«ã使ãã¯ããªã®ã§ xml ãã¡ã¤ã«ã«ã½ã¼ã¹ã®ç©çãã¹ãåºåãããªãã®ã§ã¯ã©ããããããªãã
ã¨è¨ããã¨ã§ãæ®å¿µãªãããç¾ç¶ã 㨠Jenkins CI ã使ãå ´å㯠EMMA ããã Cobertura ã使ã£ãæ¹ãè¯ãããã§ãã
Jenkins CI ã® Cobertura ãã©ã°ã¤ã³ã使ãã° ã½ã¼ã¹ãã¡ããã¨è¡¨ç¤ºããã¾ãã
ããã« html å½¢å¼ã§ã¯åºåãããªãã¡ã½ããã¬ãã«ã®éè¨ãã¡ããã¨åºåãããã®ã§é常ã«ããæãã§ãã
ãã¡ããããJenkins CI ã§ã¯ ã«ãã¬ãã¸ã®éè¨å¤ã ãåç
§ã§ããã°è¯ããã ã¦ããæ¹ã¯ EMMA ã§ãè¯ãã§ãã...
Checkstyle ã FindBugs çã§ã¯ åé¡ã®ç®æã ã½ã¼ã¹ä¸ã§åç
§ã§ããã®ã«ãã«ãã¬ãã¸ã ãåç
§ã§ããªãã®ã¯ ãªãã ã ã¡ãã£ã¨å¯ãã...
ã¨è¨ããã¨ã§ãGradle 㧠Cobertura ã使ãããã® Gradle ã¹ã¯ãªããã¯ãããªæãã§ãã
ãã¡ãããä¾ã®ãã¨ã Ant ã¿ã¹ã¯ãå©ç¨ãã¦ãã¾ãã
æ¢åã®è³ç£ããã®ã¾ã¾ä½¿ããã®ã Gradle ã®ããã¨ãã...
ãã®ã¹ã¯ãªããã§ãã£ã¦ãããã¨ã¯ ã¨ã£ã¦ãç°¡åã§ããã»ã¨ãã© EMMA ã¨åãã§ãã
test ã¿ã¹ã¯ã® doFirst 㧠class ãã¡ã¤ã«ã«ç´æ¥ã«ãã¬ãã¸æ¸¬å®ç¨ã®å¦çã追å ãã¦ã
doLast 㧠è¨æ¸¬ããã«ãã¬ãã¸ã®ã¬ãã¼ããä½æãã¦ãã¾ãã
ã¡ãªã¿ã« doFirst ã¯ãã¹ãåãdoLast ã¯ãã¹ãå¾ã« ããããå®è¡ããã¾ãã
ããããã® Gradle ã¹ã¯ãªãããå©ç¨ããå ´åã¯ãããã¸ã§ã¯ãã® gradle é ä¸ã« cobertura.gradle ã¨ãããã¡ã¤ã«åã§ä¿åãã¦ãbuild.gradle ã«
apply from: 'gradle/cobertura.gradle'ã追å ããã°è¯ãã§ãããããã¯ã
fileTree(dir: 'gradle', includes: ['*.gradle']).each { apply from: it }ã®ããã« gradle é ä¸ã® Gradle ã¹ã¯ãªãããå ¨ã¦èªã¿è¾¼ãããã«ãã¦ãããæ¹ã便å©ããããã¾ããã
å¾ã¯ test ã¿ã¹ã¯ã
gradle testã®ããã«å®è¡ããã ãã§ãã«ãã¬ãã¸ãè¨æ¸¬ã㦠build/reports/cobertura é ä¸ã«ã¬ãã¼ããä½æãã¦ããã¾ãã