Skip to content

[test] 테스트 커버리지 측정 도입#273

Merged
buzz0331 merged 2 commits into
developfrom
test/#272-jacoco-test-converage
Aug 22, 2025
Merged

[test] 테스트 커버리지 측정 도입#273
buzz0331 merged 2 commits into
developfrom
test/#272-jacoco-test-converage

Conversation

@buzz0331
Copy link
Copy Markdown
Contributor

@buzz0331 buzz0331 commented Aug 22, 2025

#️⃣ 연관된 이슈

closes #272

📝 작업 내용

jacoco를 이용해 테스트 커버리지를 측정합니다.

  1. ./gradlew clean test jacocoTestReport 커맨드 입력
  2. http://localhost:63342/THIP-Server/build/reports/jacoco/test/html/index.html로 접속

📸 스크린샷

💬 리뷰 요구사항

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

📌 PR 진행 시 이러한 점들을 참고해 주세요

* P1 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
* P2 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
* P3 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

Summary by CodeRabbit

  • 테스트

    • JaCoCo 도구(버전 0.8.12) 도입 및 테스트 실행 후 HTML/XML 보고서 자동 생성
    • 테스트 실행을 JUnit Platform으로 일원화
    • 커버리지 검증 규칙(INSTRUCTION, BRANCH)에 대한 검사 추가(최소 허용값: 0.00)
  • 작업(Chores)

    • 커버리지 보고 및 검증이 기본 빌드 검사 흐름에 통합됨

@buzz0331 buzz0331 self-assigned this Aug 22, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 22, 2025

Walkthrough

루트 build.gradle에 Jacoco 플러그인을 추가하고 외부 jacoco.gradle 스크립트를 적용했으며, jacoco.gradle에서 Jacoco 버전 설정, 테스트 실행(JUnit Platform), 리포트 생성(jacocoTestReport), 커버리지 검증(jacocoTestCoverageVerification) 및 check 연동을 추가했습니다.

Changes

Cohort / File(s) Change Summary
루트 Gradle 설정
build.gradle
jacoco Gradle 플러그인 추가 및 apply from: "$rootDir/jacoco.gradle" 추가
Jacoco 구성 및 작업
jacoco.gradle
jacoco { toolVersion = "0.8.12" } 추가; testuseJUnitPlatform()finalizedBy tasks.jacocoTestReport 적용; jacocoTestReport(type JacocoReport) 작업 추가(클래스 디렉터리 필터링, 소스 디렉터리 포함, executionData **/build/jacoco/*.exec, HTML/XML 활성화); jacocoTestCoverageVerification(type JacocoCoverageVerification) 작업 추가(동일한 클래스 필터링, 테스트 의존, CLASS 단위로 INSTRUCTION/BRANCH COVEREDRATIO 최소값 0.00 설정); checkjacocoTestCoverageVerification에 의존하도록 변경

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Dev as 개발자
    participant Gradle
    participant Test as test (JUnit Platform)
    participant Report as jacocoTestReport
    participant Verify as jacocoTestCoverageVerification
    participant Check as check

    Dev->>Gradle: gradle check
    Gradle->>Test: 테스트 실행 (useJUnitPlatform)
    Test-->>Report: finalizedBy -> 리포트 생성 트리거
    Gradle->>Report: jacoco 데이터 수집 및 HTML/XML 리포트 생성
    Note over Report: class 디렉터리 필터 적용\nexecutionData: **/build/jacoco/*.exec
    Gradle->>Verify: 커버리지 검증 실행
    Note over Verify: CLASS 단위 INSTRUCTION/BRANCH COVEREDRATIO 최소값 = 0.00
    Verify-->>Check: 검증 결과 전달
    Gradle-->>Dev: 빌드/체크 결과
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
[#272] jacoco를 이용해 테스트 커버리지를 측정하도록 설정 추가

Assessment against linked issues: Out-of-scope changes

(해당 없음)

Poem

당근 한 움큼 들고 빌드 위로 폴짝,
테스트 돌고 리포트는 반짝반짝,
숫자 0.00도 겁내지 않는 토끼,
커버리지 깃발은 살랑살랑,
오늘도 체크는 해피 엔딩! 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 29f6afd and 47acdbb.

📒 Files selected for processing (1)
  • jacoco.gradle (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • jacoco.gradle
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test/#272-jacoco-test-converage

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 22, 2025

Test Results

412 tests   412 ✅  36s ⏱️
124 suites    0 💤
124 files      0 ❌

Results for commit 47acdbb.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
build.gradle (1)

100-101: jacoco.gradle에서 useJUnitPlatform() 제거로 테스트 설정 중복 해소

검증 스크립트 결과, build.gradle(97–99)과 jacoco.gradle(5–7) 양쪽에 동일하게 useJUnitPlatform()이 선언되어 중복된 것을 확인했습니다. 유지보수 비용을 낮추기 위해 테스트 러너 선택 설정은 build.gradle에만 남기고, jacoco.gradle에서는 finalizedBy tasks.jacocoTestReport만 유지하도록 정리하세요.

  • 중복 위치
    • jacoco.gradle (lines 5–7)
    • build.gradle (lines 97–99)

  • 제안된 수정 (jacoco.gradle)

 tasks.named('test') {
-    useJUnitPlatform()
     finalizedBy tasks.jacocoTestReport
 }
jacoco.gradle (5)

5-8: useJUnitPlatform() 중복 제거 권장

현재 build.gradle에도 동일 설정이 있어 중복입니다. 테스트 러너 선택은 루트 build.gradle에서만 유지하고, 여기서는 리포트 후처리만 유지하는 편이 명확합니다.

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

27-29: additionalSourceDirs는 불필요한 중복입니다

Gradle 최신 DSL에서는 sourceDirectories만 설정하면 충분합니다. additionalSourceDirs는 중복/혼동을 야기할 수 있으므로 제거를 권장합니다.

-    additionalSourceDirs.from files(sourceSets.main.allSource.srcDirs)
     sourceDirectories.from files(sourceSets.main.allSource.srcDirs)

41-75: 커버리지 검증 범위와 임계치 정책 재고 권장

  • 현재 element = 'CLASS'로 클래스별 최소치(Instruction 80%, Branch 50%)를 강제합니다. 작은 유틸/예외 클래스 때문에 빌드가 쉽게 깨질 수 있습니다.
  • 일반적으로 “전체(또는 모듈) 기준 임계치 + 클래스 기준 완화/예외 목록” 조합을 많이 씁니다.

옵션 A(권장): 번들 기준 기본 임계치로 전환

-        rule {
-            element = 'CLASS'
+        rule {
+            element = 'BUNDLE'
             limit {
                 counter = 'INSTRUCTION'
                 value = 'COVEREDRATIO'
                 minimum = 0.80
             }
             limit {
                 counter = 'BRANCH'
                 value = 'COVEREDRATIO'
                 minimum = 0.50
             }
         }

옵션 B: 클래스 기준은 유지하되, 예외/경고 모드 도입(예: 특정 패키지 제외 또는 초소형 클래스 제외). 팀 정책에 맞춰 선택하세요.

현재 임계치로 ./gradlew check가 안정적으로 통과하는지 CI에서 한번 돌려 확인해주세요. 실패 시 어떤 클래스가 실패를 유발하는지 build/reports/jacoco/test/html과 검증 로그를 함께 첨부하면 기준 조정 논의가 수월합니다.


44-57: Querydsl 관련 제외 패턴 중복 제거

이미 **/generated/querydsl/**를 제외하므로, 아래의 **/Q*.*는 과잉입니다. 유지하려면 패키지 한정이 필요합니다(위 코멘트 참고). 중복 제거를 권장합니다.

                         "**/*Response*",
                         "**/generated/querydsl/**",
-                        "**/Q*.*"

13-25: Exclude 패턴 세분화하여 의도치 않은 클래스 제외 방지

수정 대상: jacoco.gradle 파일, 13–25줄의 exclude 블록

불필요하게 넓은 와일드카드(**/*Dto*, **/*Request*, **/*Response*, **/Q*.*)를 제거하고, 실제 사용되는 패키지 경로를 기준으로 패턴을 좁혀 적용합니다.

     exclude(
             "**/generated/**",
             "**/build/**",
             "**/*Application*",
             "**/*Config*",
-            "**/*Dto*",
-            "**/*Request*",
-            "**/*Response*",
-            "**/generated/querydsl/**",
-            "**/Q*.*"
+            // 포트 계층의 DTO 모델만 제외
+            "**/application/port/out/dto/**",
+            "**/application/port/in/dto/**",
+            // 웹 어댑터의 요청/응답 모델만 제외
+            "**/adapter/in/web/request/**",
+            "**/adapter/in/web/response/**",
+            // QueryDSL 생성 소스
+            "**/generated/querydsl/**"
     )

– 필요 시 /generated/querydsl/ 패턴 외 /Q. 제거**
– 만약 DTO/Request/Response 전체를 제외해야 한다면, 공통 패키지(**/common/dto/**, **/api/**/request/**, **/api/**/response/**) 기준으로 추가 한정하세요.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6b623e1 and 29f6afd.

📒 Files selected for processing (2)
  • build.gradle (2 hunks)
  • jacoco.gradle (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (5)
build.gradle (1)

5-5: Jacoco 플러그인 적용 OK

plugins 블록에서 id 'jacoco' 선언은 적절하며, 외부 스크립트(jacoco.gradle)의 설정과 호환됩니다.

jacoco.gradle (4)

1-3: Jacoco 버전 고정은 합리적입니다

toolVersion = "0.8.12"는 Java 17과 호환되고 널리 사용되는 안정 버전입니다. 조직 정책에 따라 “빌드 캐시 재현성”을 위해 버전 고정은 유지하는 것을 권장합니다.

조직 표준과 최신 호환성 점검이 필요하면 다음으로 확인하세요(옵션):

  • 사내 표준 플러그인 버전 표와의 일치 여부
  • Gradle 버전/자바 버전과의 호환성 릴리즈 노트

30-33: 실행 데이터 수집 패턴은 실용적입니다

**/build/jacoco/*.exec 패턴은 단일/다중 모듈 모두에서 test.exec 등을 포괄합니다. 현 시점에선 충분합니다.


34-39: 리포트 설정 LGTM

HTML/XML 활성화, CSV 비활성화 선택은 합리적입니다. CI 아티팩트 업로드 대상에 HTML을 포함시키면 리뷰가 편해집니다.


77-79: check에 커버리지 검증 연동 OK

품질 게이트로 동작하도록 check 의존성 연결이 잘 되어 있습니다. 테스트 실패 시에도 리포트 생성 보장을 원한다면, 현재의 test.finalizedBy(jacocoTestReport) 구성으로 충분합니다.

@buzz0331 buzz0331 merged commit 31decda into develop Aug 22, 2025
4 checks passed
@buzz0331 buzz0331 deleted the test/#272-jacoco-test-converage branch August 22, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[THIP2025-318] [test] 테스트 커버리지 측정기 도입

1 participant