Skip to content

perf(tests): begin conversion of tests from Robolectric to JVM - #22903

Merged
mikehardy merged 13 commits into
ankidroid:mainfrom
david-allison:backend-bump-simple
Nov 3, 2026
Merged

mikehardy merged 13 commits into
ankidroid:mainfrom
david-allison:backend-bump-simple

Conversation

@david-allison

Copy link
Copy Markdown
Member

Note

Assisted-by: GPT-6.1-Sol xhigh

Purpose / Description

This is a very small and hopefully easy-to-review slice of the CI performance work which I've been running in the background.

This kicks off the work in a small, reviewable PR, and paves the way for larger changes.

I explicitly avoided including any large changes, or changes which affected production code in this commit (besides the libanki update).

It's here... this PR isn't much yet... but it opens us up for significantly faster tests!

Fixes

Approach

  • Bump the backend to 0.1.76-anki26.09.3 + depend directly on anki-backend-core.
  • Move libanki to the JVM: replace Timber with SLF4J and split out DB helpers.
  • Unify some JvmTest functionality with RobolectricTest
  • Move a variety of tests, splitting some classes our and retaining
  • Add OnDiskJvmTest for future extension

How Has This Been Tested?

This is tests - heavily tested a larger PR where we had ~55% total test time reduction

On a subset of the tests which are affected by this PR:

31.79s -> 18.61s on my M1. 1 run

Checklist

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Use `anki-backend-core` (JVM) for local backend builds and test fixtures

https://redirect.github.com/ankidroid/Anki-Android-Backend/pull/770

Assisted-by: GPT-6.1-Sol xhigh
Remove Android runtime dependencies from libanki and use SLF4J logging.
Keep Android cursor adapters in anki-common and restrict FrameworkDatabase
to the helpers used by its callers.

Document moving shared cursor paging and conversion logic into
anki-backend-core.

Assisted-by: GPT-6.1-Sol xhigh
`JvmTest.runTest` now uses the coroutine test scheduler, allowing
ViewModel/collection tests to move away from Robolectric.

Same code as already used by Robolectric

Assisted-by: GPT-6.1-Sol xhigh
Assisted-by: GPT-6.1-Sol xhigh
InstantTaskExecutorRule (AndroidX) is used so we don't need an Android
looper.

Assisted-by: GPT-6.1-Sol xhigh
OnDiskJvmTest allows for these to execute using a temp directory for
these tests.

Assisted-by: GPT-6.1-Sol xhigh
Keeping the integration checks under the Android runner
(WorkManager-related)

Assisted-by: GPT-6.1-Sol xhigh
Run settings checks on the JVM and retain a Robolectric integration test
that verifies the factory loads the saved action and display durations.

Assisted-by: GPT-6.1-Sol xhigh

@mikehardy mikehardy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assisted-by: Grok 4.7

Thank you — splitting :libanki JVM SQL/cursor helpers from Android cursors while keeping the paging and leak checks in tests is the right foundation.

Locally I rebased onto main without force-pushing (prep stayed at the PR tip). I ran lint (lintAll, ktlintCheck, lint-rules:test), unit tests (jacocoUnitTestReport), and release emulator tests (TEST_RELEASE_BUILD=true via run_emulator_tests.py on emulator-5556 / API35_GAPI); all passed.

Reviewed the new :libanki module with Rust-backed DB/DBCursor, shared JVM test config, SLF4J logging in libanki, and moving pure JVM tests off Robolectric while WorkManager cases stay on device tests.

some acceptable findings, no action required, just leaving for posterity: libanki logs need an SLF4J provider on device; StringToLong.strtol edge cases; DB.mod still public and unused.

@mikehardy mikehardy added Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) and removed Needs Review labels Nov 3, 2026
@mikehardy
mikehardy added this pull request to the merge queue Nov 3, 2026
Merged via the queue into ankidroid:main with commit 92a882d Nov 3, 2026
24 checks passed
@github-actions github-actions Bot removed the Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) label Nov 3, 2026
@github-actions github-actions Bot added this to the 2.26 release milestone Nov 3, 2026
@david-allison
david-allison deleted the backend-bump-simple branch November 3, 2026 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants