Skip to content

Commit

Permalink
Fixed UI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzo committed Oct 20, 2023
1 parent 73eb111 commit 394bf36
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
6 changes: 3 additions & 3 deletions demo-project/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ android {
enableUnitTestCoverage = true
}
release {
aggregateTestCoverage = false

isMinifyEnabled = false
signingConfig = getByName("debug").signingConfig
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
Expand Down Expand Up @@ -68,7 +71,4 @@ dependencies {

testImplementation(libs.junit)
testImplementation(libs.robolectric)

androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.espresso)
}
27 changes: 27 additions & 0 deletions demo-project/ui-tests/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import com.android.build.api.dsl.ManagedVirtualDevice

plugins {
alias(libs.plugins.android.test)
alias(libs.plugins.android.baseline)
alias(libs.plugins.kotlin.android)
}

Expand All @@ -20,4 +23,28 @@ android {

missingDimensionStrategy("environment", "stage")
}

testOptions.managedDevices.devices {
create<ManagedVirtualDevice>("emulator") {
device = "Pixel 2"
apiLevel = android.compileSdk!!
systemImageSource = "aosp-atd"
}
}
}

val pixel2 by android.testOptions.managedDevices.devices.creating(ManagedVirtualDevice::class) {
device = "Pixel 6"
apiLevel = 30
systemImageSource = "aosp-atd"
}

baselineProfile {
useConnectedDevices = false
managedDevices += pixel2.name
}

dependencies {
implementation(libs.androidx.test.junit)
implementation(libs.androidx.test.espresso)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.myapplication", appContext.packageName)
assertEquals("com.example.app.test", appContext.packageName)
}
}
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ robolectric = "org.robolectric:robolectric:4.10.3"
android = { id = "com.android.application", version.ref = "agp" }
android-lib = { id = "com.android.library", version.ref = "agp" }
android-test = { id = "com.android.test", version.ref = "agp" }
android-baseline = { id = "androidx.baselineprofile", version = "1.2.0" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-samReceiver = { id = "org.jetbrains.kotlin.plugin.sam.with.receiver", version.ref = "kotlin" }
Expand Down

0 comments on commit 394bf36

Please sign in to comment.