Skip to content

Refactor: Ranking 도메인 관련 테스트 코드 리팩터링 및 테스트 커버리지 성능 개선 #45

Merged
Bumnote merged 2 commits intodevfrom
refactor/ranking
Jun 28, 2025
Merged

Refactor: Ranking 도메인 관련 테스트 코드 리팩터링 및 테스트 커버리지 성능 개선 #45
Bumnote merged 2 commits intodevfrom
refactor/ranking

Conversation

@Bumnote
Copy link
Copy Markdown
Member

@Bumnote Bumnote commented Jun 28, 2025

#️⃣ 연관된 이슈

#36 #41

📝 작업 내용

  • 사용되지 않는 불필요한 import문 및 변수를 제거했습니다.
  • Ranking 도메인 관련 테스트 코드를 리팩터링했습니다.
    • Service 레이어에서 Repository 레이어 테스트 진행하던 것을 Service 통합 테스트로 수정했습니다.
  • Jacoco 테스트 커버리지 성능 결과를 토대로 테스트를 보강하여 성능을 향상시켰습니다.

📍 개선 사항

  • Jacoco 테스트 커버리지 성능을 향상시켰습니다.
    • 구문 커버리지 성능을 2% 향상시켰습니다. (72% -> 74%)

수정 전

image

수정 후

image


💬 리뷰 요구사항

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


Bumnote added 2 commits June 28, 2025 03:41
- 파일명 변경으로 인한 static 상수 import문 오류를 수정했습니다.
- Ranking 도메인 관련 테스트 코드를 리팩터링했습니다.
- Service 레이어에서 Repository 기능을 불필요한 테스트를 Service 통합테스트로 수정했습니다.
- Jacoco 테스트 커버리지 성능을 2% 개선했습니다. (72% -> 74%)

issue #36
@Bumnote Bumnote requested review from Copilot and kyubumjang June 28, 2025 04:55
@Bumnote Bumnote self-assigned this Jun 28, 2025
@Bumnote Bumnote merged commit 1ac5112 into dev Jun 28, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors test code in the Ranking domain and boosts Jacoco coverage by 2%, including cleaning up imports and restructuring service-layer tests.

  • Removed unused imports and variables across tests
  • Refactored service vs. repository layer tests for Typing and Ranking domains
  • Augmented and renamed tests to cover missing scenarios (e.g., non-existent member, anonymous user)

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/test/java/dasi/typing/domain/phrase/PhraseRepositoryTest.java Adjusted random-phrase loop bound from 25 to 30
src/test/java/dasi/typing/api/service/typing/TypingServiceTest.java Renamed tests, added missing-member scenario, updated exception assertions
src/test/java/dasi/typing/api/service/ranking/RankingServiceTest.java Removed DateTimeUtil imports, simplified monthly ranking test
src/main/java/dasi/typing/api/service/phrase/PhraseService.java Updated static import from CommonConstant to ConstantUtil
Comments suppressed due to low confidence (1)

src/test/java/dasi/typing/api/service/typing/TypingServiceTest.java:66

  • [nitpick] Test method names are a mix of createTyping and createTypingTest. Choose a single consistent naming convention (with or without Test suffix) to improve readability.
  void createTypingTest() {

// given
List<Phrase> phrases = new ArrayList<>();
for (int i = 1; i <= 25; i++) {
for (int i = 1; i <= 30; i++) {
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

Using the hard-coded upper bound of 30 here can obscure intent—consider driving this from the phraseCount parameter to keep the test logic aligned with the scenario inputs.

Suggested change
for (int i = 1; i <= 30; i++) {
for (int i = 1; i <= Math.max(phraseCount, 30); i++) {

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +195
Code expectedErrorCode = assertThrows(CustomException.class, () -> {
typingService.saveTyping(authentication, serviceRequest);
}).getErrorCode();

// then
assertThat(expectedErrorCode).isEqualTo(Code.NOT_EXIST_MEMBER);
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

[nitpick] You're mixing assertThatThrownBy and JUnit's assertThrows in different tests—standardize on one style for consistent exception assertions.

Suggested change
Code expectedErrorCode = assertThrows(CustomException.class, () -> {
typingService.saveTyping(authentication, serviceRequest);
}).getErrorCode();
// then
assertThat(expectedErrorCode).isEqualTo(Code.NOT_EXIST_MEMBER);
// when & then
assertThatThrownBy(() -> typingService.saveTyping(authentication, serviceRequest))
.isInstanceOf(CustomException.class)
.extracting("errorCode")
.isEqualTo(Code.NOT_EXIST_MEMBER);

Copilot uses AI. Check for mistakes.
void getMonthlyRanking() {
void getMonthlyRankingTest() {
// given
Phrase phrase = createPhrase();
Copy link

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

The phrase is never saved before typingRepository.saveAll(typings), which can cause a foreign-key constraint failure. Add phraseRepository.save(phrase) before saving typings.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dev] Jacoco Test Coverage 측정 및 개선 [Test] 전반적인 테스트 코드 보완 및 Spring REST Docs 적용

2 participants