Skip to content

Flaky-tests: testPlayDebugUnitTest failure due to TimeZone assumptions and race conditions in ReviewerTest/AlarmManagerServiceTest #20413

@aadityarshah

Description

@aadityarshah

Checked for duplicates?

  • This issue is not a duplicate

Does it also happen in the desktop version?

  • This bug does not occur in the latest version of Anki Desktop

What are the steps to reproduce this bug?

While working on my PR #20412, I faced an issue in the JUnit Tests (macos run 1) due to which it failed. On running ./gradlew testPlayDebugUnitTest command in powershell with OpenJDK 24 version, I figured out that there were some issues in some of the test files which are described as follows:

  • AlarmManagerServiceTest.kt fails due to TimeZone mismatches when the system clock is interpreted differently.
  • ReviewerTest.kt has race conditions where assertions run before the WebView/Collection settle.
    My laptop has dual boot of Ubuntu Linux (24.0.4 LTS version) and Windows 11 and uses chrony library to keep the local time in my laptop in sync with my country's time zone (IST). That is probably one of the factors which led to these tests failing in my environment.

Expected behaviour

Since no related changes had been made in PR #20412, I expected the Unit Tests to be executed successfully but due some of the test runs are not compatible with my environment as mentioned earlier and hence, the test files need to be worked on. But I faced several errors when I ran ./gradlew testPlayDebugUnitTest in the root of the codebase. Below are the errors I faced (in short):

  • android.content.res.Resources$NotFoundException: Unable to find resource ID #0x0
  • java.lang.AssertionError: Verification failed (TimeZone Mismatch)
  • java.lang.AssertionError: expected:<1> but was:<0> (Reviewer/DeckPicker Race Conditions)

Debug info

Host Development Environment Info
- Host Laptop: ASUS Vivobook (Intel Core Ultra 5 225H)
- Host Operating System: Windows 11 (Dual boot with Ubuntu Linux 24.0.4 LTS)
- Host Architecture: x86_64
- Host TimeZone: Asia/Kolkata (GMT+5:30)
- Time Sync Service: Chrony
- Java Version: OpenJDK 24.0.1 2025-04-15 LTS
- AnkiDroid Commit: #216101a32f675ce3045e65b2934ab271493f1431
- Build System: Gradle 9.3.0, Android Studio Otter 3 Feature Drop | 2025.2.3

(Optional) Anything else you want to share?

No response

Research

  • I have checked the manual and the FAQ and could not find a solution to my issue
  • (Optional) I have confirmed the issue is not resolved in the latest alpha release (instructions)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions