diff --git a/android-ech/build.gradle.kts b/android-ech/build.gradle.kts index 698d195..61db794 100644 --- a/android-ech/build.gradle.kts +++ b/android-ech/build.gradle.kts @@ -1,7 +1,6 @@ plugins { // AGP 9 brings Kotlin support with it — applying the Kotlin Android plugin here fails. alias(libs.plugins.android.library) - alias(libs.plugins.android.junit5) } // The version of OkHttp under test. This suite defaults to the snapshot rather than to the @@ -36,22 +35,11 @@ android { // An AndroidJUnitRunner that calls OkHttp.initialize first. See EchTestRunner for why the // library's own androidx Startup initializer doesn't cover an instrumentation APK. testInstrumentationRunner = "okhttp.testbed.android.ech.EchTestRunner" - testInstrumentationRunnerArguments += - mapOf( - // The suite is JUnit 5, as the JVM suites are. - "runnerBuilder" to "de.mannodermaus.junit5.AndroidJUnit5Builder", - ) } compileOptions { sourceCompatibility(JavaVersion.VERSION_11) targetCompatibility(JavaVersion.VERSION_11) - - // JUnit 5 is compiled against Java 8 APIs — `java.util.function`, `Optional`, `java.time` — - // which Android only has from API 26. The suite runs on API 21 upwards, so without this the - // runner dies with NoClassDefFoundError on the oldest emulators in the matrix before a single - // test is reached. Desugaring is what makes "minSdk 21" true of the tests as well as the code. - isCoreLibraryDesugaringEnabled = true } testOptions { @@ -60,8 +48,6 @@ android { } dependencies { - coreLibraryDesugaring(libs.desugar.jdk.libs) - androidTestImplementation("com.squareup.okhttp3:okhttp:$okhttpVersion") androidTestImplementation("com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttpVersion") @@ -72,10 +58,8 @@ dependencies { androidTestImplementation("com.squareup.okhttp3:okhttp-android:$okhttpVersion") androidTestImplementation(libs.assertk) - androidTestImplementation(libs.junit.jupiter.api) - androidTestImplementation(libs.junit5android.core) + androidTestImplementation(libs.junit4) androidTestImplementation(libs.androidx.test.runner) - androidTestRuntimeOnly(libs.junit5android.runner) } // `check` doesn't run instrumentation tests, so the public-API check has to be wired to the diff --git a/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/EncryptedClientHelloTest.kt b/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/EncryptedClientHelloTest.kt index 7b4c8ae..3585f47 100644 --- a/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/EncryptedClientHelloTest.kt +++ b/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/EncryptedClientHelloTest.kt @@ -36,8 +36,8 @@ import okhttp3.Request import okhttp3.Response import okhttp3.Route import okhttp3.dnsoverhttps.DnsOverHttps -import org.junit.jupiter.api.Assumptions.assumeTrue -import org.junit.jupiter.api.Test +import org.junit.Assume.assumeTrue +import org.junit.Test /** * Encrypted Client Hello, end to end, against the containers `run-ech-test.sh` starts on the @@ -117,10 +117,10 @@ class EncryptedClientHelloTest { private fun fixture(): Fixture { val arguments = InstrumentationRegistry.getArguments() - assumeTrue(arguments.getString("ech") == "true", "requires the host-side ECH fixtures") + assumeTrue("requires the host-side ECH fixtures", arguments.getString("ech") == "true") assumeTrue( - Build.VERSION.SDK_INT >= TLS_13_API_LEVEL, "the ECH fixture origin is TLS 1.3 only, which Android has from API $TLS_13_API_LEVEL", + Build.VERSION.SDK_INT >= TLS_13_API_LEVEL, ) val dohPort = requireNotNull(arguments.getString("dohPort")).toInt() val caCertificate = Base64.decode(requireNotNull(arguments.getString("caCertificate")), Base64.DEFAULT) diff --git a/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/PublicEncryptedClientHelloTest.kt b/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/PublicEncryptedClientHelloTest.kt index 40bc7e7..4fd6b7e 100644 --- a/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/PublicEncryptedClientHelloTest.kt +++ b/android-ech/src/androidTest/kotlin/okhttp/testbed/android/ech/PublicEncryptedClientHelloTest.kt @@ -31,9 +31,9 @@ import okhttp3.Request import okhttp3.Response import okhttp3.Route import okhttp3.dnsoverhttps.DnsOverHttps -import org.junit.jupiter.api.Assumptions.assumeTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test +import org.junit.Assume.assumeTrue +import org.junit.Before +import org.junit.Test /** * [okhttp.testbed.network.EchTest]'s cases, on the one platform where they can all pass. @@ -56,9 +56,9 @@ import org.junit.jupiter.api.Test class PublicEncryptedClientHelloTest { private lateinit var client: OkHttpClient - @BeforeEach + @Before fun setUp() { - assumeTrue(Build.VERSION.SDK_INT >= 37, "ECH requires Android API 37") + assumeTrue("ECH requires Android API 37", Build.VERSION.SDK_INT >= 37) val bootstrapClient = OkHttpClient() diff --git a/build.gradle.kts b/build.gradle.kts index c9fe74e..8abb93b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,6 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { alias(libs.plugins.kotlin.jvm) apply false alias(libs.plugins.android.library) apply false - alias(libs.plugins.android.junit5) apply false } // The JDK the suites *run* on: what a user's application would be running when it calls the diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2c3e4f0..dd804cf 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,8 @@ [versions] agp = "9.3.1" -android-junit5 = "2.0.1" androidx-test-runner = "1.7.0" assertk = "0.28.1" -# Backports the Java 8 APIs JUnit 5 needs onto the API 21 emulators in the android-ech matrix. -desugar-jdk-libs = "2.1.5" +junit4 = "4.13.2" junit-platform = "1.14.4" kotlin = "2.4.10" # Must match the mockserver/mockserver image tag; the client refuses to talk to a @@ -28,13 +26,11 @@ testcontainers = "2.0.5" [libraries] androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test-runner" } assertk = { module = "com.willowtreeapps.assertk:assertk", version.ref = "assertk" } -desugar-jdk-libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar-jdk-libs" } +junit4 = { module = "junit:junit", version.ref = "junit4" } junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "org-junit-jupiter" } junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "org-junit-jupiter" } junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "org-junit-jupiter" } junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform" } -junit5android-core = { module = "de.mannodermaus.junit5:android-test-core", version.ref = "android-junit5" } -junit5android-runner = { module = "de.mannodermaus.junit5:android-test-runner", version.ref = "android-junit5" } mockserver = { module = "org.testcontainers:testcontainers-mockserver", version.ref = "testcontainers" } mockserver-client = { module = "org.mock-server:mockserver-client-java-no-dependencies", version.ref = "mockserver" } okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } @@ -42,6 +38,5 @@ testcontainers = { module = "org.testcontainers:testcontainers", version.ref = " testcontainers-junit5 = { module = "org.testcontainers:testcontainers-junit-jupiter", version.ref = "testcontainers" } [plugins] -android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "android-junit5" } android-library = { id = "com.android.library", version.ref = "agp" } kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } diff --git a/renovate.json b/renovate.json index 31869b2..95ff588 100644 --- a/renovate.json +++ b/renovate.json @@ -5,7 +5,7 @@ ], "packageRules": [ { - "description": "Stay on JUnit 5. JUnit 6 requires Java 17+ and a coordinated bump of the android-junit5 plugin, so it is not a drop-in upgrade here.", + "description": "Keep the JVM test suites on JUnit 5. JUnit 6 requires Java 17+, so it is not a drop-in upgrade here.", "matchManagers": [ "gradle" ],