From a92c8b2243cce88bebe4ea9ccc3cfdb587cfe989 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sun, 8 Feb 2026 15:35:18 +0100 Subject: [PATCH] Setup espresso for testing --- app/build.gradle.kts | 11 ++++++++++- gradle.properties | 3 +++ gradle/libs.versions.toml | 9 +++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bc06dfc41..3a7aaecdb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -55,6 +55,12 @@ configure { System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it } testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunnerArguments["disableAnalytics"] = "true" + testOptions { + emulatorControl { + enable = true + } + } } buildTypes { @@ -363,7 +369,10 @@ dependencies { testImplementation(libs.mockito.core) androidTestImplementation(libs.androidx.junit) - androidTestImplementation(libs.androidx.runner) + androidTestImplementation(libs.androidx.test.espresso) + androidTestImplementation(libs.androidx.test.espresso.device) + androidTestImplementation(libs.androidx.test.runner) + androidTestImplementation(libs.androidx.test.rules) androidTestImplementation(libs.androidx.room.testing) androidTestImplementation(libs.assertj.core) androidTestImplementation(platform(libs.androidx.compose.bom)) diff --git a/gradle.properties b/gradle.properties index a529a42c8..63d97f28c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,6 @@ systemProp.file.encoding=utf-8 # https://docs.gradle.org/current/userguide/configuration_cache.html org.gradle.configuration-cache=true + +# https://developer.android.com/studio/test/espresso-api#set_up_your_project_for_the_espresso_device_api +android.experimental.androidTest.enableEmulatorControl=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ff69ad774..6bce80016 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ about-libraries = "11.2.3" acra = "5.13.1" agp = "8.13.2" +androidx-test = "1.7.0" appcompat = "1.7.1" assertj = "3.27.6" autoservice-google = "1.1.1" @@ -20,6 +21,8 @@ constraintlayout = "2.2.1" core = "1.17.0" desugar = "2.1.5" documentfile = "1.1.0" +espresso = "3.7.0" +espresso-device = "1.1.0" exoplayer = "2.19.1" fragment-compose = "1.8.9" groupie = "2.10.1" @@ -47,7 +50,6 @@ preference = "1.2.1" prettytime = "5.0.8.Final" recyclerview = "1.4.0" room = "2.7.2" # Newer versions require minSdk >= 23 -runner = "1.7.0" rxandroid = "3.0.2" rxbinding = "4.0.0" rxjava = "3.1.12" @@ -102,8 +104,11 @@ androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" } androidx-room-rxjava3 = { module = "androidx.room:room-rxjava3", version.ref = "room" } androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "room" } -androidx-runner = { module = "androidx.test:runner", version.ref = "runner" } androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" } +androidx-test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" } +androidx-test-espresso-device = { module = "androidx.test.espresso:espresso-device", version.ref = "espresso-device" } +androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" } +androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" } androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "webkit" } androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "work" } androidx-work-rxjava3 = { module = "androidx.work:work-rxjava3", version.ref = "work" }