Migrate Android instrumented tests to JUnit 4#9260
Open
one-kash wants to merge 1 commit intosquare:masterfrom
Open
Migrate Android instrumented tests to JUnit 4#9260one-kash wants to merge 1 commit intosquare:masterfrom
one-kash wants to merge 1 commit intosquare:masterfrom
Conversation
JUnit 5 tests don't run on Android API 21-25 due to limitations of the android-junit5 plugin. This change migrates the android-test module to use JUnit 4 for broader device compatibility. Changes: - Replace JUnit 5 annotations with JUnit 4 equivalents - @beforeeach -> @before - @AfterEach -> @after - @disabled -> @ignore - @RegisterExtension -> removed (manual lifecycle management) - @tag -> removed (use @category if needed) - Replace JUnit 5 assertions/assumptions with JUnit 4 - Replace TestAbortedException with AssumptionViolatedException - Add @RunWith(AndroidJUnit4::class) to test classes - Remove de.mannodermaus.android-junit5 plugin - Update test instrumentation runner configuration - Manually start/stop MockWebServer in test setup/teardown - Simplify client creation without OkHttpClientTestRule Fixes square#9134
yschimke
reviewed
Jan 25, 2026
| /** | ||
| * Tests for SNI overriding on Android. | ||
| */ | ||
| @Tag("Remote") |
yschimke
reviewed
Jan 25, 2026
|
|
||
| junitPlatform { | ||
| filters { | ||
| excludeTags("Remote") |
Collaborator
There was a problem hiding this comment.
This shouldn't be removed.
Collaborator
|
@one-kash are these AI generated? Just curious because of the regular PR structure, and some weird editing choices. If so, one off. or some automated process suggesting PR fixes on public projects? |
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
Migrate the android-test module from JUnit 5 to JUnit 4 to enable tests to run on Android API 21-25.
The JUnit 5 tests weren't running on older Android versions due to limitations of the android-junit5 plugin (requires API 26+).
Changes
Annotation migrations:
@BeforeEach→@Before@AfterEach→@After@Disabled→@Ignore@Tag→ removed@RegisterExtension→ removedImport changes:
org.junit.jupiter.api.*→org.junit.*TestAbortedException→AssumptionViolatedExceptionBuild changes:
de.mannodermaus.android-junit5pluginAndroidJUnitRunnerTest infrastructure:
@RunWith(AndroidJUnit4::class)to test classes@Before/@AfterOkHttpClientTestRuleTest Plan
These tests should now run on all supported Android versions (API 21+).
Fixes #9134