2016-09-21 71 views
2

項目結構:日食 - 爪哇 - 搖籃被跳過jacocoTestReport

src/main/java 
    src/main/resources 
    src/test/java 

搖籃版本:2.2.1

這裏是我的build.gradle

apply plugin: 'java' 
    apply plugin: 'eclipse' 
    apply plugin: 'jacoco' 
    version = '1.0' 
    sourceCompatibility = 1.7 
    targetCompatibility = 1.7 

test { 
    include 'src/test/java' 
    finalizedBy jacocoTestReport 

    } 

    jacoco { 
    toolVersion = "0.7.6.201602180812" 

    } 

jacocoTestReport { 
    group = "Reporting" 
    description = "Generate Jacoco coverage reports after running tests." 
    additionalSourceDirs = files(sourceSets.main.allJava.srcDirs) 
    reports { 
     xml.enabled false 
     csv.enabled false 
     html.destination "${buildDir}/reports/jacoco/html" 
} 
} 

當我運行gradle這個任務, 「test jacocoTestReport」,我得到下面的結果

:compileJava UP-TO-DATE 
    :processResources UP-TO-DATE 
    :classes UP-TO-DATE 
    :compileTestJava UP-TO-DATE 
    :processTestResources UP-TO-DATE 
    :testClasses UP-TO-DATE 
    :test UP-TO-DATE 
    :jacocoTestReport SKIPPED 

有人可以請建議應該添加什麼來執行jacoco測試報告。

謝謝。

回答

1

我能夠通過以下設置生成代碼覆蓋率結果。

apply plugin: 'jacoco' 
jacocoTestReport { 
    reports { 
    xml.enabled false 
    csv.enabled false 
    html.destination "${buildDir}/jacocoHtml" 
} 
} 
4

該任務僅在覆蓋率數據可用時纔會運行。您也可以通過運行test任務來確保這一點。

來源 - Running jacocoReport