test: fix NotificationsRepositoryTest (android.util.Log not mocked) #29
No reviewers
Labels
No labels
auth
bug
composer
correctness
database
durability
enhancement
feeds
interactions
notifications
performance
reliability
safety
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starsetbyte/peregrine!29
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/notifications-test-android-log"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
NotificationsRepositoryTest > markAllSeen still marks local rows read when server call throwshas been failing onmain:When
updateSeenthrows,markAllSeen's catch block logs viaLog.w. In plain JVM unit tests android.jar stubs throw "not mocked", so the log call itself throws and fails the assertion. The other test passes only because it never enters the catch block.This is a test-environment issue, not a production bug —
markAllRead()runs before the server call, so the optimistic local update is correct.Fix
Enable
testOptions.unitTests.isReturnDefaultValues = trueso unmocked android.jar methods return defaults instead of throwing — the approach the "not mocked" error message itself links to. No production code changes; no Robolectric.Tradeoff: this is a global unit-test setting, so unmocked android stubs across all tests now return defaults rather than throwing. That's the conventional Android setup and the full unit suite stays green.
Verification
./gradlew :app:testDebugUnitTest— BUILD SUCCESSFUL (previously 1 failing).🤖 Generated with Claude Code
https://claude.ai/code/session_0151pbAku7AeA9fgzWKVQLPE