test infra: JUnit5 unit tests on Android modules + Compose UI test wiring
Add an architecture.android.unit.test convention plugin that runs local unit tests on the JUnit5 platform via useJUnitPlatform() (AndroidUnitTest extends Gradle's Test) + the unit-test bundle. Deliberately NOT using the de.mannodermaus plugin (targets AGP 8.x; we're on AGP 9). Add junit-platform-launcher (Gradle 9 dropped the bundled launcher); set the instrumentation runner; add a compose-ui-test bundle pinning espresso/runner to current versions (transitive espresso 3.5.0 calls the removed InputManager.getInstance() on API 34+). CI now runs ./gradlew test and compiles the instrumented tests. Drop unused testing catalog entries.
This commit is contained in:
@@ -36,12 +36,10 @@ timber = "5.0.1"
|
||||
material = "1.12.0"
|
||||
|
||||
# Testing
|
||||
junit4 = "4.13.2"
|
||||
junitJupiter = "5.11.4"
|
||||
androidJunit5 = "1.11.4"
|
||||
junitPlatform = "1.11.4"
|
||||
turbine = "1.2.0"
|
||||
assertk = "0.28.1"
|
||||
androidxTest = "1.7.0"
|
||||
androidxTestExt = "1.3.0"
|
||||
androidxTestRunner = "1.7.0"
|
||||
androidxEspresso = "3.7.0"
|
||||
@@ -97,7 +95,6 @@ koin-core = { module = "io.insert-koin:koin-core" }
|
||||
koin-android = { module = "io.insert-koin:koin-android" }
|
||||
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose" }
|
||||
koin-test = { module = "io.insert-koin:koin-test" }
|
||||
koin-test-junit5 = { module = "io.insert-koin:koin-test-junit5" }
|
||||
|
||||
# --- Ktor ---
|
||||
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
|
||||
@@ -116,13 +113,12 @@ coil-network-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version
|
||||
timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
|
||||
|
||||
# --- Testing ---
|
||||
junit4 = { module = "junit:junit", version.ref = "junit4" }
|
||||
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junitJupiter" }
|
||||
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junitJupiter" }
|
||||
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junitJupiter" }
|
||||
# Gradle 9 no longer bundles the launcher — it must be on the test runtime classpath explicitly.
|
||||
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junitPlatform" }
|
||||
turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" }
|
||||
assertk = { module = "com.willowtreeapps.assertk:assertk", version.ref = "assertk" }
|
||||
androidx-test-core = { module = "androidx.test:core", version.ref = "androidxTest" }
|
||||
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidxTestRunner" }
|
||||
androidx-test-ext-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTestExt" }
|
||||
androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "androidxEspresso" }
|
||||
@@ -147,6 +143,16 @@ ktor = [
|
||||
lifecycle-compose = ["androidx-lifecycle-runtime-compose", "androidx-lifecycle-viewmodel-compose"]
|
||||
views = ["androidx-appcompat", "material", "androidx-recyclerview", "androidx-fragment-ktx"]
|
||||
unit-test = ["junit-jupiter-api", "kotlinx-coroutines-test", "turbine", "assertk"]
|
||||
# Instrumented Compose UI test (androidTest): ComposeTestRule + AndroidJUnit4 runner.
|
||||
# espresso-core/runner are pinned to current versions: Compose's test rule drives Espresso's
|
||||
# onIdle, and the transitive espresso 3.5.0 calls InputManager.getInstance() (removed on API 34+),
|
||||
# which crashes on modern devices. 3.7.0 fixes that reflection.
|
||||
compose-ui-test = [
|
||||
"androidx-compose-ui-test-junit4",
|
||||
"androidx-test-ext-junit",
|
||||
"androidx-test-espresso-core",
|
||||
"androidx-test-runner",
|
||||
]
|
||||
|
||||
[plugins]
|
||||
# Upstream plugins
|
||||
@@ -155,8 +161,6 @@ android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
|
||||
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
|
||||
# Declared for milestone 5 (ViewModel/Compose tests on Android); wired when tests land.
|
||||
android-junit5 = { id = "de.mannodermaus.android-junit5", version.ref = "androidJunit5" }
|
||||
|
||||
# Convention plugins (defined in :build-logic, resolved from the included build)
|
||||
architecture-android-application = { id = "architecture.android.application" }
|
||||
@@ -164,6 +168,7 @@ architecture-android-library = { id = "architecture.android.library" }
|
||||
architecture-android-feature = { id = "architecture.android.feature" }
|
||||
architecture-android-feature-views = { id = "architecture.android.feature.views" }
|
||||
architecture-domain-module = { id = "architecture.domain.module" }
|
||||
architecture-android-unit-test = { id = "architecture.android.unit.test" }
|
||||
architecture-compose = { id = "architecture.compose" }
|
||||
architecture-koin = { id = "architecture.koin" }
|
||||
architecture-ktor = { id = "architecture.ktor" }
|
||||
|
||||
Reference in New Issue
Block a user