Try to use Gradle managed devices.

https://developer.android.com/studio/test/gradle-managed-devices
This commit is contained in:
Benoit Marty 2022-10-12 11:33:44 +02:00 committed by Benoit Marty
parent 36e5166051
commit 9e6f615f1c
5 changed files with 100 additions and 1 deletions

View File

@ -87,5 +87,5 @@ task unitTestsWithCoverage(type: GradleBuild) {
task instrumentationTestsWithCoverage(type: GradleBuild) {
startParameter.projectProperties.coverage = [enableTestCoverage: true]
startParameter.projectProperties['android.testInstrumentationRunnerArguments.notPackage'] = 'im.vector.app.ui'
tasks = [':vector-app:connectedGplayDebugAndroidTest', ':vector:connectedDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest']
tasks = [':vector-app:pixel2api30AtdGplayDebugAndroidTest', ':vector:pixel2api30AtdDebugAndroidTest', 'matrix-sdk-android:pixel2api30AtdDebugAndroidTest']
}

View File

@ -19,6 +19,10 @@ android.enableJetifier=true
android.jetifier.ignorelist=android-base-common,common
android.useAndroidX=true
# Test settings
# Ref: https://developer.android.com/studio/test/gradle-managed-devices#gmd-sharding
android.experimental.androidTest.numManagedDeviceShards=2
#Project Settings
# Change debugPrivateData to true for debugging
vector.debugPrivateData=false

View File

@ -1,3 +1,5 @@
import com.android.build.api.dsl.ManagedVirtualDevice
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
@ -76,6 +78,36 @@ android {
testOptions {
// Comment to run on Android 12
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
// Ref: https://developer.android.com/studio/test/gradle-managed-devices
managedDevices {
devices {
// Run test with ./gradlew pixel2api28GplayDebugAndroidTest
pixel2api28(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// Use only API levels 27 and higher.
apiLevel = 28
// To include Google services, use "google". Else "aosp"
systemImageSource = "google"
}
// Ref: https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd
// Run test with ./gradlew pixel2api30AtdGplayDebugAndroidTest
// Warning: Screenshot tests that depend on hardware rendering currently aren't supported when using ATDs.
pixel2api30Atd(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// ATDs currently support only API level 30.
apiLevel = 30
// You can also specify "google-atd" if you require Google Play Services, else "aosp-atd"
systemImageSource = "google-atd"
}
// there is also a wat to create group of devices, but this is not necessary for now:
// https://developer.android.com/studio/test/gradle-managed-devices#gmd-groups
}
}
// On GitHub action, add: -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
}
buildTypes {

View File

@ -1,4 +1,5 @@
import com.android.build.OutputFile
import com.android.build.api.dsl.ManagedVirtualDevice
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.appdistribution'
@ -211,6 +212,36 @@ android {
// Comment to run on Android 12
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
// Ref: https://developer.android.com/studio/test/gradle-managed-devices
managedDevices {
devices {
// Run test with ./gradlew pixel2api28GplayDebugAndroidTest
pixel2api28(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// Use only API levels 27 and higher.
apiLevel = 28
// To include Google services, use "google". Else "aosp"
systemImageSource = "google"
}
// Ref: https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd
// Run test with ./gradlew pixel2api30AtdGplayDebugAndroidTest
// Warning: Screenshot tests that depend on hardware rendering currently aren't supported when using ATDs.
pixel2api30Atd(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// ATDs currently support only API level 30.
apiLevel = 30
// You can also specify "google-atd" if you require Google Play Services, else "aosp-atd"
systemImageSource = "google-atd"
}
// there is also a wat to create group of devices, but this is not necessary for now:
// https://developer.android.com/studio/test/gradle-managed-devices#gmd-groups
}
}
// On GitHub action, add: -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
}
signingConfigs {

View File

@ -1,3 +1,5 @@
import com.android.build.api.dsl.ManagedVirtualDevice
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
@ -65,6 +67,36 @@ android {
// Comment to run on Android 12
// execution 'ANDROIDX_TEST_ORCHESTRATOR'
// Ref: https://developer.android.com/studio/test/gradle-managed-devices
managedDevices {
devices {
// Run test with ./gradlew pixel2api28GplayDebugAndroidTest
pixel2api28(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// Use only API levels 27 and higher.
apiLevel = 28
// To include Google services, use "google". Else "aosp"
systemImageSource = "google"
}
// Ref: https://developer.android.com/studio/test/gradle-managed-devices#gmd-atd
// Run test with ./gradlew pixel2api30AtdGplayDebugAndroidTest
// Warning: Screenshot tests that depend on hardware rendering currently aren't supported when using ATDs.
pixel2api30Atd(ManagedVirtualDevice) {
// Use device profiles you typically see in Android Studio.
device = "Pixel 2"
// ATDs currently support only API level 30.
apiLevel = 30
// You can also specify "google-atd" if you require Google Play Services, else "aosp-atd"
systemImageSource = "google-atd"
}
// there is also a wat to create group of devices, but this is not necessary for now:
// https://developer.android.com/studio/test/gradle-managed-devices#gmd-groups
}
}
// On GitHub action, add: -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect"
}
buildTypes {
debug {