Skip to content

Instantly share code, notes, and snippets.

@th-deng
th-deng / build.gradle
Created January 23, 2020 15:02
Config JacocoTaskExtension
// groovy DSL
test {
jacoco {
destinationFile = file("$buildDir/jacoco/jacoco.exec")
}
}
@th-deng
th-deng / build.gradle
Created January 23, 2020 15:04
Default JacocoTaskExtension settings
// groovy DSL
test {
jacoco {
enabled = true
destinationFile = file("$buildDir/jacoco/${name}.exec")
includes = []
excludes = []
excludeClassLoaders = []
includeNoLocationClasses = false
@th-deng
th-deng / build.gradle
Created January 23, 2020 15:12
Add task ordering
// groovy DSL
test {
// ... (생략) ...
finalizedBy 'jacocoTestReport'
}
jacocoTestReport {
// ... (생략) ...
@th-deng
th-deng / build.gradle
Created January 23, 2020 15:18
Config coverage validation rules
// groovy DSL
jacocoTestCoverageVerification {
violationRules {
rule {
// 'element'가 없으면 프로젝트의 전체 파일을 합친 값을 기준으로 한다.
limit {
// 'counter'를 지정하지 않으면 default는 'INSTRUCTION'
// 'value'를 지정하지 않으면 default는 'COVEREDRATIO'
minimum = 0.30
@th-deng
th-deng / build.gradle
Last active January 23, 2020 15:50
Apply JaCoCo plugin
// groovy DSL
plugins {
id 'jacoco'
}
jacoco {
// JaCoCo 버전
toolVersion = '0.8.5'
@th-deng
th-deng / build.gradle
Last active January 23, 2020 15:59
Using JUnitPlatform
// groovy DSL
test {
useJUnitPlatform()
}
@th-deng
th-deng / build.gradle
Last active January 23, 2020 16:00
Create the task that creates report and verifies coverages
// groovy DSL
task testCoverage(type: Test) {
group 'verification'
description 'Runs the unit tests with coverage'
dependsOn(':test',
':jacocoTestReport',
':jacocoTestCoverageVerification')
@th-deng
th-deng / build.gradle
Last active January 23, 2020 16:11
Exclude classes from coverage violation rules
// groovy DSL
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
limit {
counter = 'LINE'
@th-deng
th-deng / build.gradle
Last active January 5, 2022 06:29
Config JaCoCo report and violation rules
// groovy DSL
jacocoTestReport {
reports {
// 원하는 리포트를 켜고 끌 수 있습니다.
html.enabled true
xml.enabled false
csv.enabled false
// 각 리포트 타입 마다 리포트 저장 경로를 설정할 수 있습니다.