Skip to content

refactor(libanki): migrate TestClass and rename TestClass to AnkiTest#18813

Merged
mikehardy merged 2 commits intoankidroid:mainfrom
david-allison:libanki-testclass
Jul 20, 2025
Merged

refactor(libanki): migrate TestClass and rename TestClass to AnkiTest#18813
mikehardy merged 2 commits intoankidroid:mainfrom
david-allison:libanki-testclass

Conversation

@david-allison
Copy link
Member

@david-allison david-allison commented Jul 7, 2025

Most of libanki testing requires JvmTest

  • JvmTest uses the AnkiTest interface
  • RobolectricTest uses the AnkiTest interface

In order to move JvmTest out of AnkiDroid and into something libanki can use, we first need to move AnkiTest

AnkiTest must be usable by libanki/test and AnkiDroid/test, so define a new module: libanki:testutils to avoid a circular dependency, without exposing test-related classes to the non-test AnkiDroid.

Then, break up the dependencies, and move AnkiTest and a few dependencies to libanki:testutils

Fixes

How Has This Been Tested?

Unit test only
I haven't checked AndroidTest, will trust CI

Learning

This is not fun, but it's nearly over

Context Parameters would be useful architecturally, soon... 😆

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

@david-allison david-allison changed the title refactor(libanki): add libanki:testutils, migrate TestClass and rename to AnkiTest refactor(libanki): add libanki:testutils, migrate TestClass and rename TestClass to AnkiTest Jul 7, 2025
@david-allison david-allison marked this pull request as draft July 11, 2025 00:41
@david-allison
Copy link
Member Author

david-allison commented Jul 11, 2025

@david-allison david-allison added the Blocked by dependency Currently blocked by some other dependent / related change label Jul 13, 2025
@david-allison david-allison changed the title refactor(libanki): add libanki:testutils, migrate TestClass and rename TestClass to AnkiTest refactor(libanki): migrate TestClass and rename TestClass to AnkiTest Jul 18, 2025
@david-allison david-allison added Needs Review and removed Blocked by dependency Currently blocked by some other dependent / related change Has Conflicts labels Jul 18, 2025
@david-allison david-allison marked this pull request as ready for review July 18, 2025 15:23
`com.ichi2.testutils.TestClass`

=>

`com.ichi2.anki.libanki.testutils.TestClass`

No Android/AnkiDroid references allow this to occur

Rationale:
Most of the libanki tests rely on `JvmTest`, which relies on `TestClass`

This is the next step in moving these tests across to `libanki`
which should speed up our test process

Issue 18015
`com.ichi2.anki.libanki.testutils.TestClass`
`com.ichi2.anki.libanki.testutils.AnkiTest`

This is now for 'LibAnki' only, enforced by the module
the name makes the intention of the class much more clear
@mikehardy mikehardy added this pull request to the merge queue Jul 20, 2025
Merged via the queue into ankidroid:main with commit b36bf3d Jul 20, 2025
10 checks passed
@github-actions github-actions bot added this to the 2.22 release milestone Jul 20, 2025
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