Hi,
ich kämpfe gerade in einem Projekt damit dass ich die Code Coverage meiner Unittests ermitteln will, jedoch gibt mir Jacoco diese nicht für alle Klassen.
Ich hab eine Main Gradle File und darin ein Service Modul und ein Shared Code Modul. Im Service Modul sind die Unittests und das Modul mit Shared Code wird anhand von einigen Klassen referenziert/verwendet.
Aber Jacoco ist der Meinung dass die Codeabeckung des Shared Code Moduls 0 ist.
Irgendwer eine Idee?
Main Gradle File
buildscript {
ext {
springBootVersion = '1.4.1.RELEASE'
project.version = version = '0.2.1-SNAPSHOT'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
plugins {
id "org.sonarqube" version "2.1"
}
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'jacoco'
test {
ignoreFailures = true
}
task codeCoverageReport(type: JacocoReport) {
// Gather execution data from all subprojects
// (change this if you e.g. want to calculate unit test/integration test coverage separately)
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
// Add all relevant sourcesets from the subprojects
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.enabled true
html.enabled true
html.destination "${buildDir}/reports/jacoco"
csv.enabled false
}
}
// always run the tests before generating the report
codeCoverageReport.dependsOn {
subprojects*.test
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile project(':shared')
compile project(':service')
}```
Service Gradle
```apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'idea'
apply plugin: 'jacoco'
test {
ignoreFailures = true
}
war {
baseName = 'BFP'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-rest")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.postgresql:postgresql')
compile project(':shared')
testCompile('org.springframework.boot:spring-boot-starter-test')
testRuntime('com.h2database:h2')
}
Shared Module
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'idea'
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("com.fasterxml.jackson.core:jackson-annotations")
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')
}