2015-03-17 5 views
8

मैंने ग्रेडल जैकोको प्लगइन का उपयोग कर वसंत-ग्रेडल प्रोजेक्ट में कोड कवरेज प्राप्त करने का प्रयास किया है।ग्रेडल jacocoTestReport काम नहीं कर रहा है?

build.gradle शामिल निम्नलिखित

apply plugin: "jacoco" 

    jacoco { 
     toolVersion = "0.7.1.201405082137" 
     reportsDir = file("$buildDir/customJacocoReportDir") 
    } 

    jacocoTestReport { 
    reports { 
     xml.enabled false 
     csv.enabled false 
     html.destination "${buildDir}/jacocoHtml" 
    } 
} 

मैं तो

gradle test jacocoTestReport 

कहाँ के बाद ही फ़ाइल test.exec निर्माण/रिपोर्ट फ़ोल्डर में उत्पन्न होता है भाग गया।

इसके अलावा कुछ भी नहीं होता है।

मैं HTML रिपोर्ट कैसे प्राप्त कर सकता हूं?

उत्तर

5

निम्नलिखित मदद मिली। इसके नमूनों में/परीक्षण/gradle-2.3-all.zip

apply plugin: "java" 

apply plugin: "jacoco" 

jacoco { 
    toolVersion = "0.7.1.201405082137" 
    reportsDir = file("$buildDir/customJacocoReportDir") 
} 

repositories { 
    mavenCentral() 
} 

dependencies { 
    testCompile "junit:junit:4.+" 
} 

test { 
    jacoco { 
     append = false 
     destinationFile = file("$buildDir/jacoco/jacocoTest.exec") 
     classDumpFile = file("$buildDir/jacoco/classpathdumps") 
    } 
} 


jacocoTestReport { 
    reports { 
     xml.enabled false 
     csv.enabled false 
     html.destination "${buildDir}/jacocoHtml" 
    } 
} 
+0

इसे भी जांचें - http://csiebler.github.io/blog/2014/02/09/multi-project-code-coverage-using-gradle-and-jacoco/ –

1

की jacaco आप क्योंकि jacoco उनके लिए डिफ़ॉल्ट मान है reportsDir/destinationFile

कॉन्फ़िगर करने के लिए नहीं है।

build.gradle:

plugins { 
    id 'java' 
    id 'jacoco' 
} 

jacocoTestReport { 
    reports { 
     xml.enabled true 
     html.enabled true 
     csv.enabled true 
    } 
} 

repositories { 
    jcenter() 
} 

dependencies { 
    testCompile group: 'junit', name: 'junit', version: '4.12' 
} 

भागो gradle test jacocoTestReport

आप ./build/reports/jacoco/test निर्देशिका में परीक्षण रिपोर्ट मिल सकता है।

एचटीएमएल आउटपुट ./build/reports/jacoco/test/html निर्देशिका में है।

संबंधित मुद्दे