test: ViewModel unit test 인프라 추가 및 첫 테스트 작성#391
Conversation
MockK/Turbine/coroutines-test 의존성을 추가하고 MyPageViewModel, VisitorModeManager에 대한 unit test를 작성해 AI 기반 개발 시 회귀를 자동으로 잡아낼 수 있는 안전망을 구축한다.
📝 WalkthroughWalkthroughThree new test dependencies ( ChangesUnit test additions
Sequence Diagram(s)sequenceDiagram
participant Test as MyPageViewModelTest
participant VM as MyPageViewModel
participant Repo as UserRepository (mock)
Test->>VM: dispatch LoadUserInfo
VM->>Repo: getUserInfo()
Repo-->>VM: emit Result.success(userInfo)
VM-->>Test: state(isLoading=false, user fields set, error=null)
Test->>VM: dispatch LoadUserInfo (failure)
VM->>Repo: getUserInfo()
Repo-->>VM: throw RuntimeException
VM-->>Test: state(isLoading=false, error="네트워크 오류 (unknown)")
VM-->>Test: effect ShowError emitted
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app/src/test/java/com/runnect/runnect/presentation/mypage/MyPageViewModelTest.kt (1)
102-104: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAssert
ShowErrormessage payload as well.This currently validates only the effect type; an incorrect message would still pass. Assert the emitted
ShowErrormessage matches the expected error string.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/test/java/com/runnect/runnect/presentation/mypage/MyPageViewModelTest.kt` around lines 102 - 104, The MyPageViewModelTest assertion only checks that the emitted effect is MyPageEffect.ShowError, so an incorrect message payload could still pass. Update the test around the effectTurbine.awaitItem() check to also verify the ShowError message matches the expected error string, using the MyPageEffect.ShowError symbol to locate the assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@app/src/test/java/com/runnect/runnect/presentation/mypage/MyPageViewModelTest.kt`:
- Around line 102-104: The MyPageViewModelTest assertion only checks that the
emitted effect is MyPageEffect.ShowError, so an incorrect message payload could
still pass. Update the test around the effectTurbine.awaitItem() check to also
verify the ShowError message matches the expected error string, using the
MyPageEffect.ShowError symbol to locate the assertion.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1599d79c-2026-4a62-a622-466b45e80c2f
📒 Files selected for processing (4)
app/build.gradleapp/src/test/java/com/runnect/runnect/presentation/event/VisitorModeManagerTest.ktapp/src/test/java/com/runnect/runnect/presentation/mypage/MyPageViewModelTest.ktgradle/libs.versions.toml
작업 배경
변경 사항
gradle/libs.versions.toml,app/build.gradleMyPageViewModelTest.ktLoadUserInfo성공/실패,UpdateNickname인텐트에 대한 상태 전이 테스트 3건VisitorModeManagerTest.ktmockkObject로PreferenceManager모킹, Robolectric 없이 plain JVM 테스트)영향 범위
testImplementation스코프)Test Plan
./gradlew :app:testDebugUnitTest전체 통과 확인./gradlew :app:assembleDebug정상 빌드 확인🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Chores