Improve unit test coverage: Firebase, Authenticator, ViewModels, Room DAO#19
Merged
Conversation
Tests verify that all safe wrappers (safeRecordException, safeLog, safeSetCustomKey) correctly delegate to FirebaseCrashlytics and swallow exceptions when GMS/Crashlytics is unavailable, preventing app crashes on cars that just received an OTA update. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover token retrieval (happy path and error paths for invalid type and null account), intent bundle returned when no cached password, and the no-op/unsupported stubs required by AbstractAccountAuthenticator. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover pingServer status-200/non-200/exception paths, login error paths, and the loginSuccess side-effects (account storage and loggedIn LiveData) via reflection. Adds core-testing for InstantTaskExecutorRule and room-testing for upcoming DAO tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests verify logout delegates to accountManager and mediaCacheDao, sends ACTION_STOP_PLAYBACK intent to DashTuneMusicService, and clears all six playback-state keys from SharedPreferences. Uses a spy on the Robolectric Application to stub startService (Hilt service initialisation is incompatible with unit tests) while preserving real SharedPreferences. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests cover all DAO operations: insert/replace, getItem, getChildrenByParent (including sort-order guarantee), getParentIds, deleteByParent, deleteAll, and hasData. Also validates that all entity fields round-trip correctly through the schema, catching any silent type-conversion issues in Room annotations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
safeRecordException,safeLog,safeSetCustomKey× 3 overloads) delegate correctly and swallow exceptions when GMS is unavailable — the production guard for cars just after an OTA update.AccountAuthenticatorcontract —getAuthTokenhappy path (cached token), error paths (invalid type, null account, no stored password→intent bundle), and all no-op stubs.pingServer(200/non-200/exception),loginerror paths, andloginSuccessside-effects (account storage,loggedInLiveData) via reflection. Addscore-testingforInstantTaskExecutorRule.logoutcallsaccountManager.logout()andmediaCacheDao.deleteAll(), sends the correctACTION_STOP_PLAYBACKintent, and clears all six playback-state SharedPreferences keys. Uses a spy on the Robolectric Application to stubstartService(Hilt service init is incompatible with unit tests).hasData, and a full entity field round-trip test.androidx-arch-core-testingandandroidx-room-testingto the test dependency set.Before → After: 11/26 source files tested (42%) → 16/26 (62%), adding ~67 new test methods.
Test plan
./gradlew :automotive:testDebugUnitTest— all tests green🤖 Generated with Claude Code