diff --git a/demo-project/app/build.gradle.kts b/demo-project/app/build.gradle.kts index 1ee808e..8329d41 100644 --- a/demo-project/app/build.gradle.kts +++ b/demo-project/app/build.gradle.kts @@ -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") } } @@ -68,7 +71,4 @@ dependencies { testImplementation(libs.junit) testImplementation(libs.robolectric) - - androidTestImplementation(libs.androidx.test.junit) - androidTestImplementation(libs.androidx.test.espresso) } diff --git a/demo-project/ui-tests/build.gradle.kts b/demo-project/ui-tests/build.gradle.kts index bb1c3ca..0f290e2 100644 --- a/demo-project/ui-tests/build.gradle.kts +++ b/demo-project/ui-tests/build.gradle.kts @@ -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) } @@ -20,4 +23,28 @@ android { missingDimensionStrategy("environment", "stage") } + + testOptions.managedDevices.devices { + create("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) } diff --git a/demo-project/ui-tests/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt b/demo-project/ui-tests/src/main/kotlin/com/example/myapplication/ExampleInstrumentedTest.kt similarity index 89% rename from demo-project/ui-tests/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt rename to demo-project/ui-tests/src/main/kotlin/com/example/myapplication/ExampleInstrumentedTest.kt index 85542d2..0d17fa1 100644 --- a/demo-project/ui-tests/src/androidTest/java/com/example/myapplication/ExampleInstrumentedTest.kt +++ b/demo-project/ui-tests/src/main/kotlin/com/example/myapplication/ExampleInstrumentedTest.kt @@ -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) } -} \ No newline at end of file +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fce0bfc..1eebf41 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" }