💻문제점
jacoco 코드 커버리지 적용했다. 이제 jacoco Report에 추가하지 않을 패키지나 클래스를 제외해보자.
🔍해결
build.gradle
jacocoTestReport {
reports {
html.required = true
xml.required = false
csv.required = false
}
excludedClassFilesForReport(classDirectories)
dependsOn test
finalizedBy 'jacocoTestCoverageVerification'
}
jacocoTestCoverageVerification {
excludedClassFilesForReport(classDirectories)
violationRules {
rule {
element = 'CLASS'
enabled = true
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
//minimum = 0.90
}
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
//minimum = 0.90
}
}
}
}
private excludedClassFilesForReport(classDirectories) {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"com/konggogi/veganlife/global/**/*",
"com/konggogi/veganlife/**/dto/**",
"**/OauthService.class",
"**/*domain*/**",
"**/*Dto*",
"**/*Request*",
"**/*Response*",
"**/*Interceptor*",
"**/*Application*",
"**/*Mapper*",
"**/*Exception*"
])
})
)
}
global 패키지 하위의 모든 패키지, 클래스,
패키지에 dto, domain이 들어가는 패키지와 하위 클래스,
클래스명에 Request, Response 등이 들어가는 클래스는 모두 제외했다.
그리고 Lombok으로 생성된 코드 역시 제외하기 위해 lombok.config를 생성했다. (Root 하위)
lombok.config
lombok.addLombokGeneratedAnnotation = true
exclude한 클래스와 패키지 제외하고 jacoco Report가 생성된다.
728x90
'TIL' 카테고리의 다른 글
[TIL - 20240103] Spring Data JPA @Modifying 문제 (0) | 2024.01.03 |
---|---|
[TIL - 20231228] Interface의 default 메서드를 활용한 Enum 확장 (0) | 2023.12.28 |
[TIL - 20231222] AuthenticationEntryPoint를 사용한 JWT 예외 핸들링 (1) | 2023.12.22 |
[TIL - 20231222] searchWeeklyIntakeCalories 로직 개선 (0) | 2023.12.22 |
[TIL-20231222] Illegal pop() with non-matching JdbcValuesSourceProcessingState (0) | 2023.12.22 |