Skip to content

Commit 4d27223

Browse files
committed
Setup espresso for testing
1 parent b8de859 commit 4d27223

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

app/build.gradle.kts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ configure<ApplicationExtension> {
5555
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
5656

5757
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
58+
testInstrumentationRunnerArguments["disableAnalytics"] = "true"
59+
testOptions {
60+
emulatorControl {
61+
enable = true
62+
}
63+
}
5864
}
5965

6066
buildTypes {
@@ -363,7 +369,10 @@ dependencies {
363369
testImplementation(libs.mockito.core)
364370

365371
androidTestImplementation(libs.androidx.junit)
366-
androidTestImplementation(libs.androidx.runner)
372+
androidTestImplementation(libs.androidx.test.espresso)
373+
androidTestImplementation(libs.androidx.test.espresso.device)
374+
androidTestImplementation(libs.androidx.test.runner)
375+
androidTestImplementation(libs.androidx.test.rules)
367376
androidTestImplementation(libs.androidx.room.testing)
368377
androidTestImplementation(libs.assertj.core)
369378
androidTestImplementation(platform(libs.androidx.compose.bom))

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ systemProp.file.encoding=utf-8
55

66
# https://docs.gradle.org/current/userguide/configuration_cache.html
77
org.gradle.configuration-cache=true
8+
9+
# https://developer.android.com/studio/test/espresso-api#set_up_your_project_for_the_espresso_device_api
10+
android.experimental.androidTest.enableEmulatorControl=true

gradle/libs.versions.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
about-libraries = "11.2.3"
88
acra = "5.13.1"
99
agp = "8.13.2"
10+
androidx-test = "1.7.0"
1011
appcompat = "1.7.1"
1112
assertj = "3.27.6"
1213
autoservice-google = "1.1.1"
@@ -20,6 +21,8 @@ constraintlayout = "2.2.1"
2021
core = "1.17.0"
2122
desugar = "2.1.5"
2223
documentfile = "1.1.0"
24+
espresso = "3.7.0"
25+
espresso-device = "1.1.0"
2326
exoplayer = "2.19.1"
2427
fragment-compose = "1.8.9"
2528
groupie = "2.10.1"
@@ -47,7 +50,6 @@ preference = "1.2.1"
4750
prettytime = "5.0.8.Final"
4851
recyclerview = "1.4.0"
4952
room = "2.7.2" # Newer versions require minSdk >= 23
50-
runner = "1.7.0"
5153
rxandroid = "3.0.2"
5254
rxbinding = "4.0.0"
5355
rxjava = "3.1.12"
@@ -102,8 +104,11 @@ androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref =
102104
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
103105
androidx-room-rxjava3 = { module = "androidx.room:room-rxjava3", version.ref = "room" }
104106
androidx-room-testing = { module = "androidx.room:room-testing", version.ref = "room" }
105-
androidx-runner = { module = "androidx.test:runner", version.ref = "runner" }
106107
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" }
108+
androidx-test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
109+
androidx-test-espresso-device = { module = "androidx.test.espresso:espresso-device", version.ref = "espresso-device" }
110+
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidx-test" }
111+
androidx-test-runner = { module = "androidx.test:runner", version.ref = "androidx-test" }
107112
androidx-webkit = { module = "androidx.webkit:webkit", version.ref = "webkit" }
108113
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "work" }
109114
androidx-work-rxjava3 = { module = "androidx.work:work-rxjava3", version.ref = "work" }

0 commit comments

Comments
 (0)