Skip to content

Commit

Permalink
chore: jacoco 기본 세팅 (#28)
Browse files Browse the repository at this point in the history
* chore: jacoco 기본 설정

* chore: jacoco 커버리지 임시 주석

* chore: jacoco excludes constant화 및 buildDir 수정

* chore: checkstyle remove
  • Loading branch information
char-yb authored Nov 29, 2023
1 parent fd75684 commit 96999f4
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'com.diffplug.spotless' version '6.11.0'
id 'jacoco'
}

group = 'com.depromeet'
Expand Down Expand Up @@ -40,6 +41,74 @@ tasks.named('bootBuildImage') {

tasks.named('test') {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
}

jacoco {
toolVersion = "0.8.8"
}

def jacocoDir = layout.buildDirectory.dir("reports/")

def QDomains = []
for (qPattern in '*.QA'..'*.QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
QDomains.add(qPattern + '*')
}

def jacocoExcludePatterns = [
// 측정 안하고 싶은 패턴
"**/*Application*",
"**/*Config*",
"**/*Exception*",
"**/*Request*",
"**/*Response*",
"**/*Dto*",
"**/*Interceptor*",
"**/*Filter*",
"**/*Resolver*"
]

jacocoTestReport {
dependsOn test
reports {
html.required.set(true)
xml.required.set(true)
csv.required.set(true)
html.destination jacocoDir.get().file("jacoco/index.html").asFile
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
csv.destination jacocoDir.get().file("jacoco/index.csv").asFile
}

afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: jacocoExcludePatterns + QDomains) // Querydsl 관련 제거
})
)
}
finalizedBy jacocoTestCoverageVerification
}

jacocoTestCoverageVerification {

violationRules {
rule {
// rule 활성화
enabled = true

// 클래스 단위로 룰 체크
element = 'CLASS'

// 라인 커버리지를 최소 80% 만족
// limit {
// counter = 'LINE'
// value = 'COVEREDRATIO'
// minimum = 0.80
// }

excludes = jacocoExcludePatterns + QDomains
}
}
}

jar.enabled = false
Expand Down

0 comments on commit 96999f4

Please sign in to comment.