Conversation
- Mockk, Coroutines Test 라이브러리 의존성을 추가 - 테스트 시 Android 프레임워크에 의존적인 코드에 대해 기본 값을 반환하도록 `testOptions`를 설정
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
app/build.gradle.kts
Outdated
| testOptions { | ||
| unitTests.isReturnDefaultValues = true | ||
| } |
There was a problem hiding this comment.
당시에 로컬 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) |
There was a problem hiding this comment.
c: 앞으로 테스트를 어느범위까지 적용시킬 생각이신가요?
범위에 따라 테스트 의존성을 플러그인에 추가해도 좋을 것 같아서요
There was a problem hiding this comment.
현재는 도메인 레이어 모델과 하나의 UseCase에 대해서만 로컬 유닛 테스트를 작성한 상태입니다.
추후 테스트 범위가 확장될 경우에는 의존성 관리 방식도 함께 정리하여, 모듈별 개별 추가보다는 공통 플러그인으로 관리하는 방향을 고려하겠습니다..!
|
|
||
| class AttractivePointsTest { | ||
|
|
||
| @Test |
There was a problem hiding this comment.
c: 이 아래로 gwt주석이 없는데, 유즈케이스 테스트랑 코드 스타일이 통일되면 좋을 것 같아요 주석이 다 있거나 아예 다 없거나!
개인적으론 유즈케이스에서 gwt로 문단나눠주신게 더 잘 읽혔습니다!
Added steps to run unit tests and upload test reports.
There was a problem hiding this comment.
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
📒 Files selected for processing (10)
.github/workflows/WSS_PR_builder.ymlapp/build.gradle.ktsapp/src/test/java/com/into/websoso/domain/usecase/GetSearchedNovelsUseCaseTest.ktdomain/library/build.gradle.ktsdomain/library/src/test/java/com/into/websoso/domain/library/model/AttractivePointsTest.ktdomain/library/src/test/java/com/into/websoso/domain/library/model/NovelRatingTest.ktdomain/library/src/test/java/com/into/websoso/domain/library/model/RatingTest.ktdomain/library/src/test/java/com/into/websoso/domain/library/model/ReadStatusesTest.ktdomain/library/src/test/java/com/into/websoso/domain/library/model/SortCriteriaTest.ktgradle/libs.versions.toml
| 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) | ||
| } |
There was a problem hiding this comment.
// 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.
| 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" |
There was a problem hiding this comment.
🧩 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:
- JUnit is no longer pulled in transitively (breaking for some builds)
- MockK changed its JUnit 4/5 dependencies from
implementationtocompileOnly, 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.)
- Settings-file precedence changed
- MockK now prioritizes
mockk.propertiesin 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:
- 1: https://github.com/mockk/mockk/releases/tag/1.14.9
- 2: Change JUnit 4/5 dependencies from implementation to compileOnly mockk/mockk#1455
🌐 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/resources→src/test/resourcesforio/mockk/settings.properties, and includesmockk.propertiesunder test resources. If you previously shipped these inmain, you’ll need to relocate them for tests. [2]
- Docs/config guidance changed from
-
1.14.5 (Jul 16, 2025): BDD aliases moved into separate artifacts
- BDD-style aliases (
given,then, etc.) are provided via new modulesmockk-bdd/mockk-bdd-android; using those APIs now requires adding those dependencies. [3]
- BDD-style aliases (
-
1.14.9 (Jan 26, 2026): JUnit no longer comes as a transitive dependency
- MockK changed JUnit 4/5 dependencies from
implementationtocompileOnly, which can break builds/tests that relied on MockK bringing JUnit onto the classpath transitively. [1]
- MockK changed JUnit 4/5 dependencies from
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.
✅ Android CI 요약
🎉 SUCCESS! 🎉 |
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴
Summary by CodeRabbit
릴리스 노트
Tests
Chores