From 3b8c591477f2f884eee02b8c0716d2ebac0b946f Mon Sep 17 00:00:00 2001 From: JunRain Date: Fri, 7 Jun 2024 22:01:28 +0900 Subject: [PATCH] =?UTF-8?q?[#100]=20Jacoco=20gradle=20=EC=84=A4=EC=A0=95?= =?UTF-8?q?=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/memetory/build.gradle | 65 +++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/backend/memetory/build.gradle b/backend/memetory/build.gradle index 7ddad5f..d236277 100644 --- a/backend/memetory/build.gradle +++ b/backend/memetory/build.gradle @@ -3,6 +3,7 @@ plugins { id 'org.springframework.boot' version '3.2.2' id 'io.spring.dependency-management' version '1.1.4' id 'com.google.cloud.tools.jib' version '3.4.1' + id 'jacoco' } group = 'com.example' @@ -70,8 +71,67 @@ clean { delete file('src/main/generated') } -tasks.named('test') { +test { useJUnitPlatform() + finalizedBy 'jacocoTestReport' +} + +jacocoTestReport { + reports { + xml.required.set(false) + csv.required.set(true) + html.required.set(true) + } + def Qdomains = [] + + for (qPattern in '**/QA'..'**/QZ') { + Qdomains.add(qPattern + '*') + } + + afterEvaluate { + classDirectories.setFrom( + files(classDirectories.files.collect { + fileTree(dir: it, + excludes: ["**/dto/**", + "**/exception/**", + "**/userInfo/**", + "com/example/memetory/MemetoryApplication.class" + ] + Qdomains) + }) + + ) + } + + finalizedBy 'jacocoTestCoverageVerification' +} + +jacocoTestCoverageVerification { + def Qdomains = [] + + for (qPattern in '*.QA'..'*.QZ') { + Qdomains.add(qPattern + '*') + } + + + violationRules { + rule { + enabled = true + element = 'CLASS' + + limit { + counter = 'METHOD' + value = 'COVEREDRATIO' + minimum = 0.00 + } + + limit { + counter = 'INSTRUCTION' + value = 'COVEREDRATIO' + minimum = 0.00 + } + excludes = [] + Qdomains + } + } } jib { @@ -90,4 +150,5 @@ jib { container { jvmFlags = ['-Dspring.profiles.active=dev'] } -} \ No newline at end of file +} +