Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Flaky test: PrefsSearchBarTest

Open david-allison opened this issue 11 months ago • 7 comments

test: All indexed XML resIDs lead to the correct fragments on getFragmentFromXmlRes

On my M1 MacBook, private branch off 120ae9e3e1cc9d74ae1cd9c93f87cf18d6a122d9

W/OverlayConfig: partition_order.xml does not exist.
W/PackageParser: Unknown element under <manifest>: queries at /Users/davidallison/StudioProjects/Anki-Android/AnkiDroid/build/intermediates/apk_for_local_test/fullDebugUnitTest/packageFullDebugUnitTestForUnitTest/apk-for-local-test.ap_ Binary XML file line #86
W/PackageParser: No actions in intent filter at /Users/davidallison/StudioProjects/Anki-Android/AnkiDroid/build/intermediates/apk_for_local_test/fullDebugUnitTest/packageFullDebugUnitTestForUnitTest/apk-for-local-test.ap_ Binary XML file line #454
W/ACRA: ACRA#init called more than once. This might have unexpected side effects. Doing this outside of tests is discouraged.
I/ACRA: ACRA is enabled for com.ichi2.anki.debug, initializing...
D/AnkiDroid: Startup - Application Start
I/AnkiDroidApp: Timber config: ROBOLECTRIC
I/UsageAnalytics: initialize()
D/UsageAnalytics: Chaining to uncaughtExceptionHandler (org.acra.reporter.ErrorReporterImpl@4c106d0d)
I/UsageAnalytics: setOptIn(): from false to false
I/GoogleAnalyticsImpl: Not participating in analytics sample (sample percentage vs random: 10 81)
D/UsageAnalytics: setOptIn() optIn / sAnalytics.config().enabled(): false/false
I/UsageAnalytics: setDryRun(): true, warning dryRun is experimental
I/ThrowableFilterService: initialize()
D/ThrowableFilterService: Chaining to uncaughtExceptionHandler (com.ichi2.anki.analytics.UsageAnalytics$$Lambda/0x0000000800dc4f20@40a4865e)
I/AnkiDroidApp$onCreate: AnkiDroidApp: listing debug info
D/TestUtilsKt: isRunningAsUnitTest: true
D/SystemContextMenu: Modifying Context Menu Status: Preference was true
I/NotificationChannelsKt: Creating notification channel with id/name: General Notifications/AnkiDroid
I/NotificationChannelsKt: Creating notification channel with id/name: Synchronization/Synchronization
I/NotificationChannelsKt: Creating notification channel with id/name: Review Reminders/Review Reminders
I/AnkiDroidApp: Setting review reminder notifications if they have not already been set
D/AlarmManagerService$Companion: scheduleAllEnabledReviewReminderNotifications
D/DayRolloverHandler: listening for rollover events
D/TtsVoices: job already started
V/FailOnUnhandledExceptionRule$apply: test: applying exception handler override
-- executing test "All indexed XML resIDs lead to the correct fragments on getFragmentFromXmlRes"
D/ChangeManager: clearing 1 subscribers
D/MetaDB: Closing MetaDB
I/Themes: Setting theme to LIGHT
I/AnkiDroidApp$onCreate: PreferencesActivity::onCreate, savedInstanceState: null
I/ScopedStorageService: isLegacyStorage(): false
D/SingleFragmentActivity: Creating fragment com.ichi2.anki.preferences.PreferencesFragment
I/AnkiDroidApp$onCreate: PreferencesActivity::onStart
I/FragmentLifecycleLogger: PreferencesActivity::PreferencesFragment::onAttach
I/FragmentLifecycleLogger: PreferencesActivity::PreferencesFragment::onCreate
I/FragmentLifecycleLogger: PreferencesActivity::HeaderFragment::onAttach
D/UsageAnalytics: sendAnalyticsScreenView(): prefs.initialPage
D/UsageAnalytics: getOptIn() status: false
D/Backend: Opening rust backend with lang=[en-US]
I/FragmentLifecycleLogger: PreferencesActivity::HeaderFragment::onCreate
I/FragmentLifecycleLogger: PreferencesActivity::HeaderFragment::onViewCreated
I/FragmentLifecycleLogger: PreferencesActivity::PreferencesFragment::onViewCreated
I/FragmentLifecycleLogger: PreferencesActivity::HeaderFragment::onStart
I/FragmentLifecycleLogger: PreferencesActivity::PreferencesFragment::onStart
I/AnkiDroidApp$onCreate: PreferencesActivity::onResume
D/UsageAnalytics: sendAnalyticsScreenView(): PreferencesActivity
D/UsageAnalytics: getOptIn() status: false
I/FragmentLifecycleLogger: PreferencesActivity::HeaderFragment::onResume
I/FragmentLifecycleLogger: PreferencesActivity::PreferencesFragment::onResume
I/RobolectricTest: closeCollection: RobolectricTest: End
-- completed test "All indexed XML resIDs lead to the correct fragments on getFragmentFromXmlRes"

actual value is null ==> expected: not <null>
org.opentest4j.AssertionFailedError: actual value is null ==> expected: not <null>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:159)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:139)
	at org.junit.jupiter.api.AssertNotNull.failNull(AssertNotNull.java:55)
	at org.junit.jupiter.api.AssertNotNull.assertNotNull(AssertNotNull.java:40)
	at org.junit.jupiter.api.Assertions.assertNotNull(Assertions.java:334)
	at kotlin.test.junit5.JUnit5Asserter.assertNotNull(JUnitSupport.kt:48)
	at kotlin.test.AssertionsKt__AssertionsKt.assertNotNull(Assertions.kt:145)
	at kotlin.test.AssertionsKt.assertNotNull(Unknown Source)
	at kotlin.test.AssertionsKt__AssertionsKt.assertNotNull$default(Assertions.kt:143)
	at kotlin.test.AssertionsKt.assertNotNull$default(Unknown Source)
	at com.ichi2.anki.preferences.PrefsSearchBarTest.All indexed XML resIDs lead to the correct fragments on getFragmentFromXmlRes(PrefsSearchBarTest.kt:70)
	Suppressed: org.robolectric.android.internal.AndroidTestEnvironment$UnExecutedRunnablesException: Main looper has queued unexecuted runnables. This might be the cause of the test failure. You might need a shadowOf(Looper.getMainLooper()).idle() call.

david-allison avatar Dec 24 '25 09:12 david-allison

Good first issue: update the test so on failure, the resId and resourceEntryName are logged, so we know where the failure came from

david-allison avatar Dec 24 '25 09:12 david-allison

"Hi @david-allison, I've made a contribution to open source before, and I'd love to help with this issue as my next step. It looks like a great way to get more familiar with Anki-Android. May I be assigned to this?"

largeblueberry avatar Dec 24 '25 10:12 largeblueberry

Hi, can i please get this issue assigned?

hemampandey avatar Dec 24 '25 19:12 hemampandey

@hemampandey Would you able to reproduce this bug ?

sanjaysargam avatar Dec 24 '25 20:12 sanjaysargam

yes, I was able to reproduce this bug by forcing fragments to be null. before: Image after:

Image

hemampandey avatar Dec 24 '25 20:12 hemampandey

@hemampandey Go ahead.

sanjaysargam avatar Dec 24 '25 20:12 sanjaysargam

Unable to find resource ID #0x0
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x0
	at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:318)
	at android.content.res.Resources.getResourceName(Resources.java:2341)
	at com.ichi2.anki.preferences.PrefsSearchBarTest.All indexed XML resIDs lead to the correct fragments on getFragmentFromXmlRes(PrefsSearchBarTest.kt:70)
	Suppressed: org.robolectric.android.internal.AndroidTestEnvironment$UnExecutedRunnablesException: Main looper has queued unexecuted runnables. This might be the cause of the test failure. You might need a shadowOf(Looper.getMainLooper()).idle() call.

david-allison avatar Jan 06 '26 02:01 david-allison