Skip to content

feat: domain model 테스트 코드 작성#798

Open
devfeijoa wants to merge 15 commits intorelease/1.6.0from
feat/790
Open

feat: domain model 테스트 코드 작성#798
devfeijoa wants to merge 15 commits intorelease/1.6.0from
feat/790

Conversation

@devfeijoa
Copy link

@devfeijoa devfeijoa commented Jan 24, 2026

📌𝘐𝘴𝘴𝘶𝘦𝘴

📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯

  • 테스트에 필요한 라이브러리 의존성 추가
  • domain의 library model의 테스트 코드 작성

📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵

💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴

Summary by CodeRabbit

릴리스 노트

  • Tests

    • 도메인 모델 및 검색 기능에 대한 단위 테스트 추가
  • Chores

    • CI 워크플로우에 자동화된 테스트 실행 및 리포트 수집 기능 추가

@devfeijoa devfeijoa requested review from m6z1 and s9hn January 24, 2026 05:29
@devfeijoa devfeijoa self-assigned this Jan 24, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 24, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/790

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@s9hn s9hn left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

Comment on lines 76 to 78
testOptions {
unitTests.isReturnDefaultValues = true
}
Copy link
Member

Choose a reason for hiding this comment

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

a: 어떤 옵션인가요?

Copy link
Author

@devfeijoa devfeijoa Feb 20, 2026

Choose a reason for hiding this comment

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

당시에 로컬 unit test에서 Android 플랫폼 API를 건드리는 코드가 있어서, 예외로 테스트가 터지니까 일단 기본값으로 바꿔서 테스트를 돌리려고 임의로 넣어뒀던 설정입니다.
또한 옵션은 null 혹은 0으로 흘러가면서 버그가 가려질 수 있어서 해당 옵션 삭제하였습니다!
9804de8

https://developer.android.com/training/testing/local-tests#error

dependencies {
implementation(projects.core.common)
implementation(projects.data.library)
testImplementation(libs.junit)
Copy link
Member

Choose a reason for hiding this comment

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

c: 앞으로 테스트를 어느범위까지 적용시킬 생각이신가요?
범위에 따라 테스트 의존성을 플러그인에 추가해도 좋을 것 같아서요

Copy link
Author

Choose a reason for hiding this comment

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

현재는 도메인 레이어 모델과 하나의 UseCase에 대해서만 로컬 유닛 테스트를 작성한 상태입니다.
추후 테스트 범위가 확장될 경우에는 의존성 관리 방식도 함께 정리하여, 모듈별 개별 추가보다는 공통 플러그인으로 관리하는 방향을 고려하겠습니다..!


class AttractivePointsTest {

@Test
Copy link
Member

Choose a reason for hiding this comment

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

c: 이 아래로 gwt주석이 없는데, 유즈케이스 테스트랑 코드 스타일이 통일되면 좋을 것 같아요 주석이 다 있거나 아예 다 없거나!
개인적으론 유즈케이스에서 gwt로 문단나눠주신게 더 잘 읽혔습니다!

Copy link
Author

@devfeijoa devfeijoa Feb 20, 2026

Choose a reason for hiding this comment

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

주석 없는 테스트 케이스 모두 gwt으로 통일하였습니다!
1c05a89

Copy link
Member

@m6z1 m6z1 left a comment

Choose a reason for hiding this comment

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

좋아요 👍
이든이 시간이 난다면 테스트 코드 CI 도 추가해봐도 좋을 것 같아요!
CI 에서 테스트 코드 빌드 후 conversation 으로 답변 오도록!

Added steps to run unit tests and upload test reports.
Copy link

@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: 2

🧹 Nitpick comments (2)
.github/workflows/WSS_PR_builder.yml (1)

64-68: ./gradlew build가 이미 단위 테스트를 실행하므로 ./gradlew test는 중복 실행입니다.

Gradle의 표준 라이프사이클에서 build = assemble + check이며, Android Gradle Plugin도 이를 따릅니다. check 태스크는 로컬 단위 테스트를 포함하므로 ./gradlew build 실행 후 ./gradlew test를 실행하면 테스트가 두 번 수행되어 CI 시간이 낭비됩니다.

빌드 실패와 테스트 실패를 명확히 구분하려면 다음과 같이 변경을 권장합니다.

♻️ 빌드와 테스트 단계 분리 제안
-      - name: Build with Gradle
-        run: ./gradlew build
-
-      - name: Run Unit Tests
-        run: ./gradlew test
+      - name: Build with Gradle
+        run: ./gradlew assemble
+
+      - name: Run Unit Tests
+        run: ./gradlew test
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/WSS_PR_builder.yml around lines 64 - 68, The CI currently
runs "./gradlew build" and then "./gradlew test", causing tests to run twice;
update the workflow so build and test are separated—replace the "Build with
Gradle" command "./gradlew build" with "./gradlew assemble" (or another
assemble-only task) and keep the "Run Unit Tests" step using "./gradlew test",
ensuring the jobs "Build with Gradle" and "Run Unit Tests" reflect assemble vs
test to avoid duplicate test execution.
app/src/test/java/com/into/websoso/domain/usecase/GetSearchedNovelsUseCaseTest.kt (1)

78-85: coVerifyOrder로 캐시 삭제 → fetch 순서를 명시적으로 검증하세요.

현재 coVerify(exactly = 1)은 두 호출의 존재만 확인하지만, 구현 로직상 순서가 중요하므로 coVerifyOrder를 사용하면 더 명확합니다. MockK는 coVerifyOrder/coVerifySequence를 suspend 함수에서 지원합니다.

🔧 예시 변경안
-            coVerify(exactly = 1) {
-                novelRepository.clearCachedNormalExploreResult()
-                novelRepository.fetchNormalExploreResult(
-                    searchWord = "새로운 웹소설",
-                    page = 0,
-                    size = 20,
-                )
-            }
+            coVerifyOrder {
+                novelRepository.clearCachedNormalExploreResult()
+                novelRepository.fetchNormalExploreResult(
+                    searchWord = "새로운 웹소설",
+                    page = 0,
+                    size = 20,
+                )
+            }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@app/src/test/java/com/into/websoso/domain/usecase/GetSearchedNovelsUseCaseTest.kt`
around lines 78 - 85, Replace the unordered coVerify check with an ordered
verification so the test asserts that
novelRepository.clearCachedNormalExploreResult() is called before
novelRepository.fetchNormalExploreResult(...); specifically, change the
verification to use MockK's coVerifyOrder (or coVerifySequence) around the two
calls (referencing novelRepository.clearCachedNormalExploreResult and
novelRepository.fetchNormalExploreResult with the same arguments: searchWord =
"새로운 웹소설", page = 0, size = 20) to enforce and document the expected call order.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@domain/library/src/test/java/com/into/websoso/domain/library/model/RatingTest.kt`:
- Around line 36-46: The test method `매칭되지 않는 값은 기본 평점으로 처리된다` has the `// when`
comment left-aligned at column 0; fix the formatting by indenting the `// when`
comment to match the other comments in this file (align with the surrounding
test comments in RatingTest.kt), keeping the comment directly above the block
that calls Rating.from and ensuring consistent indentation style for this test
method.

In `@gradle/libs.versions.toml`:
- Line 41: libs.versions.toml currently pins MockK at "1.13.10"; when you
upgrade the mockk entry to "1.14.9" be sure to add an explicit JUnit test
dependency because MockK 1.14.9 no longer brings JUnit transitively: update
build.gradle to include either testImplementation("junit:junit:4.13.2") for
JUnit4 or testImplementation("org.junit.jupiter:junit-jupiter:<version>") for
JUnit5, and verify test resource locations and any BDD alias changes per the
1.14.x release notes.

---

Nitpick comments:
In @.github/workflows/WSS_PR_builder.yml:
- Around line 64-68: The CI currently runs "./gradlew build" and then "./gradlew
test", causing tests to run twice; update the workflow so build and test are
separated—replace the "Build with Gradle" command "./gradlew build" with
"./gradlew assemble" (or another assemble-only task) and keep the "Run Unit
Tests" step using "./gradlew test", ensuring the jobs "Build with Gradle" and
"Run Unit Tests" reflect assemble vs test to avoid duplicate test execution.

In
`@app/src/test/java/com/into/websoso/domain/usecase/GetSearchedNovelsUseCaseTest.kt`:
- Around line 78-85: Replace the unordered coVerify check with an ordered
verification so the test asserts that
novelRepository.clearCachedNormalExploreResult() is called before
novelRepository.fetchNormalExploreResult(...); specifically, change the
verification to use MockK's coVerifyOrder (or coVerifySequence) around the two
calls (referencing novelRepository.clearCachedNormalExploreResult and
novelRepository.fetchNormalExploreResult with the same arguments: searchWord =
"새로운 웹소설", page = 0, size = 20) to enforce and document the expected call order.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 58f85bf and 590f8d5.

📒 Files selected for processing (10)
  • .github/workflows/WSS_PR_builder.yml
  • app/build.gradle.kts
  • app/src/test/java/com/into/websoso/domain/usecase/GetSearchedNovelsUseCaseTest.kt
  • domain/library/build.gradle.kts
  • domain/library/src/test/java/com/into/websoso/domain/library/model/AttractivePointsTest.kt
  • domain/library/src/test/java/com/into/websoso/domain/library/model/NovelRatingTest.kt
  • domain/library/src/test/java/com/into/websoso/domain/library/model/RatingTest.kt
  • domain/library/src/test/java/com/into/websoso/domain/library/model/ReadStatusesTest.kt
  • domain/library/src/test/java/com/into/websoso/domain/library/model/SortCriteriaTest.kt
  • gradle/libs.versions.toml

Comment on lines +36 to +46
fun `매칭되지 않는 값은 기본 평점으로 처리된다`() {
// when
val negative = Rating.from(-1.0f)
val unmatched = Rating.from(4.7f)
val overflow = Rating.from(100.0f)

// then
assertEquals(Rating.DEFAULT, negative)
assertEquals(Rating.DEFAULT, unmatched)
assertEquals(Rating.DEFAULT, overflow)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

// when 주석 들여쓰기 누락

Line 37의 // when 주석이 들여쓰기 없이 컬럼 0에 위치해 있어, 나머지 테스트 메서드들과 스타일이 불일치합니다.

🛠️ 수정 제안
     fun `매칭되지 않는 값은 기본 평점으로 처리된다`() {
-// when
+        // when
         val negative = Rating.from(-1.0f)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fun `매칭되지 않는 값은 기본 평점으로 처리된다`() {
// when
val negative = Rating.from(-1.0f)
val unmatched = Rating.from(4.7f)
val overflow = Rating.from(100.0f)
// then
assertEquals(Rating.DEFAULT, negative)
assertEquals(Rating.DEFAULT, unmatched)
assertEquals(Rating.DEFAULT, overflow)
}
fun `매칭되지 않는 값은 기본 평점으로 처리된다`() {
// when
val negative = Rating.from(-1.0f)
val unmatched = Rating.from(4.7f)
val overflow = Rating.from(100.0f)
// then
assertEquals(Rating.DEFAULT, negative)
assertEquals(Rating.DEFAULT, unmatched)
assertEquals(Rating.DEFAULT, overflow)
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@domain/library/src/test/java/com/into/websoso/domain/library/model/RatingTest.kt`
around lines 36 - 46, The test method `매칭되지 않는 값은 기본 평점으로 처리된다` has the `//
when` comment left-aligned at column 0; fix the formatting by indenting the `//
when` comment to match the other comments in this file (align with the
surrounding test comments in RatingTest.kt), keeping the comment directly above
the block that calls Rating.from and ensuring consistent indentation style for
this test method.

junit = "4.13.2"
androidx-test-junit = "1.3.0"
espresso-core = "3.7.0"
mockk = "1.13.10"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

MockK latest version 2024 2025 Maven Central

💡 Result:

For Maven Central artifact io.mockk:mockk:

  • Latest overall (as of Feb 24, 2026): 1.14.9 (released Jan 26, 2026) [1]
  • Latest released in 2025: 1.14.7 (released Dec 6, 2025) [2]
  • Latest released in 2024: 1.13.14 (released Dec 20, 2024) [2]

The same latest version (1.14.9) is also shown for related artifacts like io.mockk:mockk-jvm and io.mockk:mockk-agent-jvm on Maven Central mirrors/indexes. [3] [4]

Sources: [1] [2] [3] [4]


🌐 Web query:

MockK 1.14.9 breaking changes Android unit testing

💡 Result:

MockK 1.14.9 doesn’t introduce Android-specific API breakage, but it can break Android unit-test builds in a couple of practical ways:

  1. JUnit is no longer pulled in transitively (breaking for some builds)
  • MockK changed its JUnit 4/5 dependencies from implementation to compileOnly, so your test runtime may no longer have JUnit unless you declare it yourself. This was done because MockK’s transitive JUnit deps could cause tooling (e.g., Maven Surefire) to auto-detect JUnit 5 and skip JUnit 4 tests. [1], [2]
    Fix (Gradle examples):
testImplementation("junit:junit:4.13.2") // if using MockKRule / JUnit4
// or
testImplementation("org.junit.jupiter:junit-jupiter:5.x.x") // if using MockKExtension / JUnit5

(Use the appropriate one for your test framework.)

  1. Settings-file precedence changed
  • MockK now prioritizes mockk.properties in its settings resolution, which can change behavior if you previously relied on another settings file being picked up first. [1]

Sources:
[1] MockK v1.14.9 release notes (GitHub) (github.com)
[2] PR #1455 (“Change JUnit 4/5 dependencies from implementation to compileOnly”) (github.com)

Citations:


🌐 Web query:

MockK version 1.14.x changelog breaking changes

💡 Result:

MockK 1.14.x — notable “breaking” / migration-relevant changes

  • 1.14.2 (Apr 29, 2025): MockK config file locations moved to test source set

    • Docs/config guidance changed from src/main/resourcessrc/test/resources for io/mockk/settings.properties, and includes mockk.properties under test resources. If you previously shipped these in main, you’ll need to relocate them for tests. [2]
  • 1.14.5 (Jul 16, 2025): BDD aliases moved into separate artifacts

    • BDD-style aliases (given, then, etc.) are provided via new modules mockk-bdd / mockk-bdd-android; using those APIs now requires adding those dependencies. [3]
  • 1.14.9 (Jan 26, 2026): JUnit no longer comes as a transitive dependency

    • MockK changed JUnit 4/5 dependencies from implementation to compileOnly, which can break builds/tests that relied on MockK bringing JUnit onto the classpath transitively. [1]

Sources: GitHub releases / PRs for MockK. [1] [2] [3]


MockK를 1.14.9로 업그레이드 시 JUnit 의존성 선언 필수

최신 버전 1.14.9는 Maven Central에서 2026년 1월에 릴리스되었습니다. 다만 이 버전으로 업그레이드할 때는 다음의 breaking change를 고려해야 합니다:

  • JUnit이 더 이상 transitive dependency로 제공되지 않습니다 (1.14.9): MockK이 JUnit 4/5 의존성을 implementation에서 compileOnly로 변경했으므로, JUnit을 명시적으로 선언해야 합니다.

업그레이드 시 build.gradle에 아래와 같이 JUnit을 추가로 선언하세요:

testImplementation("junit:junit:4.13.2")  // JUnit 4 사용 시
// 또는
testImplementation("org.junit.jupiter:junit-jupiter:5.x.x")  // JUnit 5 사용 시

이외에도 1.14.x 버전에서는 설정 파일 위치 변경(src/test/resources로 이동)과 BDD alias 분리 등의 변경사항이 있으니 릴리스 노트를 참고하세요.

♻️ 버전 업그레이드 제안
-mockk = "1.13.10"
+mockk = "1.14.9"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@gradle/libs.versions.toml` at line 41, libs.versions.toml currently pins
MockK at "1.13.10"; when you upgrade the mockk entry to "1.14.9" be sure to add
an explicit JUnit test dependency because MockK 1.14.9 no longer brings JUnit
transitively: update build.gradle to include either
testImplementation("junit:junit:4.13.2") for JUnit4 or
testImplementation("org.junit.jupiter:junit-jupiter:<version>") for JUnit5, and
verify test resource locations and any BDD alias changes per the 1.14.x release
notes.

Added permissions for contents, pull requests, and issues. Updated test command to run debug unit tests and added a step to publish unit test reports as PR comments.
Updated the workflow to run unit tests and post results as a PR comment using GitHub Actions.
@github-actions
Copy link

✅ Android CI 요약

  • Unit Tests: ✅ 성공

🎉 SUCCESS! 🎉
로그: https://github.com/Team-WSS/WSS-Android/actions/runs/22352022284

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.

3 participants