Skip to content

Instantly share code, notes, and snippets.

@rhamedy
Created July 6, 2020 00:35
Show Gist options
  • Save rhamedy/85a0a2b4642a18015220037ce195a647 to your computer and use it in GitHub Desktop.
Save rhamedy/85a0a2b4642a18015220037ce195a647 to your computer and use it in GitHub Desktop.
Java Spring Boot with JaCoCo Code Coverage with Gradle
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'eclipse'
id 'jacoco'
}
group = 'codecov.article'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}
jacoco {
toolVersion = "0.8.5"
reportsDir = file("$buildDir/jacoco")
}
test {
useJUnitPlatform()
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 1
}
}
}
}
@bethkrish
Copy link

Thanks!
This is what exactly I am after!

@sajeethpasha
Copy link

Thanks for exmplain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment