Skip to content

Commit e1d08b5

Browse files
committed
cicd: Jacoco 테스트 제외 패턴추가
- 테스트 커버리지 제외 패턴 추가
1 parent d3ba567 commit e1d08b5

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

build.gradle

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,11 @@ repositories {
2929
}
3030

3131
jacoco {
32-
toolVersion = "0.8.12"
33-
}
34-
35-
//QueryDSL 제외 패턴
36-
def QDomains = []
37-
for (qPattern in '*.QA'..'*.QZ') { // qPattern = '*.QA', '*.QB', ... '*.QZ'
38-
QDomains.add(qPattern + '*')
32+
toolVersion = "0.8.8"
3933
}
4034

35+
def QDomains = ["**/Q*"]
4136
def jacocoExcludePatterns = [
42-
// 측정 안하고 싶은 패턴
4337
"**/*Application*",
4438
"**/*Config*",
4539
"**/*Exception*",
@@ -50,43 +44,75 @@ def jacocoExcludePatterns = [
5044
"**/*Filter*",
5145
"**/*Resolver*",
5246
"**/*Entity*",
53-
"**/*Volunteer*",
54-
"**/*Location*",
5547
"**/test/**",
5648
"**/resources/**",
5749
"**/domain/**"
5850
]
59-
51+
def combinedExcludePatterns = jacocoExcludePatterns + QDomains
6052

6153
jacocoTestCoverageVerification {
62-
6354
violationRules {
6455
rule {
65-
// rule 활성화
6656
enabled = true
67-
68-
// 클래스 단위로 룰 체크
6957
element = 'CLASS'
7058

71-
7259
limit {
7360
counter = 'LINE'
7461
value = 'COVEREDRATIO'
7562
minimum = 0.60
7663
}
7764

78-
7965
limit {
8066
counter = 'BRANCH'
8167
value = 'COVEREDRATIO'
8268
minimum = 0.60
8369
}
8470

85-
excludes = jacocoExcludePatterns + QDomains
8671
}
8772
}
8873
}
8974

75+
def jacocoDir = layout.buildDirectory.dir("reports/")
76+
77+
jacocoTestReport {
78+
dependsOn test
79+
reports {
80+
html.required.set(true)
81+
xml.required.set(true)
82+
csv.required.set(true)
83+
html.destination jacocoDir.get().file("jacoco/index.html").asFile
84+
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
85+
csv.destination jacocoDir.get().file("jacoco/index.csv").asFile
86+
}
87+
88+
afterEvaluate {
89+
classDirectories.setFrom(
90+
files(classDirectories.files.collect {
91+
fileTree(dir: it,
92+
excludes: [
93+
"**/*Application*",
94+
"**/*Config*",
95+
"**/*Exception*",
96+
"**/*Request*",
97+
"**/*Response*",
98+
"**/*Dto*",
99+
"**/jwt/**",
100+
"**/*Interceptor*",
101+
"**/*Filter*",
102+
"**/*Resolver*",
103+
"**/*Entity*",
104+
"**/test/**",
105+
"**/resources/**",
106+
"**/domain/**"
107+
] + QDomains)
108+
})
109+
)
110+
}
111+
finalizedBy jacocoTestCoverageVerification
112+
}
113+
114+
115+
90116

91117
sonar {
92118
properties {
@@ -136,26 +162,6 @@ tasks.named('test') {
136162
finalizedBy 'jacocoTestReport'
137163
}
138164

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

141-
jacocoTestReport {
142-
dependsOn test // 테스트가 수행되어야만 report를 생성할 수 있도록 설정
143-
reports {
144-
html.required.set(true)
145-
xml.required.set(true)
146-
csv.required.set(true)
147-
html.destination jacocoDir.get().file("jacoco/index.html").asFile
148-
xml.destination jacocoDir.get().file("jacoco/index.xml").asFile
149-
csv.destination jacocoDir.get().file("jacoco/index.csv").asFile
150-
}
151166

152-
afterEvaluate {
153-
classDirectories.setFrom(
154-
files(classDirectories.files.collect {
155-
fileTree(dir: it, excludes: jacocoExcludePatterns + QDomains) // Querydsl 관련 제거
156-
})
157-
)
158-
}
159-
finalizedBy jacocoTestCoverageVerification
160167

161-
}

0 commit comments

Comments
 (0)