android / android-test

An extensive framework for testing Android apps
https://android.github.io/android-test
Apache License 2.0
1.16k stars 315 forks source link

Instrumentation command failed with non zero exit code when use Gradle Managed Devices #2201

Closed AlexDeww closed 7 months ago

AlexDeww commented 7 months ago

Description

I try launch tests via gradle :app:pixel2api33GoogleDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.affectedModules=:module1,:module2,etc.

If the length of affectedModules is more than 510 chars, I get error Instrumentation command failed with non zero exit code and Starting 0 tests on pixel2api33, but if the length is less than 510, all tests launch normally (Starting 53 tests on pixel2api33).

Also, if I use connectedGoogleDebugAndroidTest instead of pixel2api33GoogleDebugAndroidTest with large length of affectedModules, then tests launch normally too.

AndroidX Test and Android OS Versions

Gradle 8.2
------------------------------------------------------------

Build time:   2023-06-30 18:02:30 UTC
Revision:     5f4a070a62a31a17438ac998c2b849f4f6892877

Kotlin:       1.8.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          11.0.10 (Oracle Corporation 11.0.10+8-LTS-162)
OS:           Windows 10 10.0 amd64
defaultConfig {
    ...
    testInstrumentationRunner = "ru.home.testapp.testingcore.runner.AndroidUiTestRunner"
    testInstrumentationRunnerArguments["clearPackageData"] = "true"
}

testOptions {
    execution = "ANDROIDX_TEST_ORCHESTRATOR"

    animationsDisabled = true
    unitTests.isReturnDefaultValues = true
    unitTests.isIncludeAndroidResources = true

    managedDevices {
        localDevices {
            create("pixel2api33") {
                device = "Pixel 2"
                apiLevel = 33
                systemImageSource = "aosp"
                require64Bit = true
            }
        }
    }
}
espresso:3.5.1
kaspresso:1.5.5
androidx.arch.core:core-testing:2.2.0
androidx.test:core-ktx:1.5.0
androidx.test:rules:1.5.0
androidx.test:runner:1.5.2
androidx.test:orchestrator:1.4.2
androidx.test.ext:junit-ktx:1.1.5
brettchabot commented 7 months ago

It is expected there will be a character length limitation here. Instrumentation arguments can provided via a 'adb shell am instrument' shell command

I don't know why there would be a difference between gradle managed device tasks vs connectedAndroidTest tasks - perhaps the former adds additional arguments to the shell . But I suggest filing this bug against Android Studio where it will reach folks more familiar with the gradle tasks https://issuetracker.google.com/issues?q=componentid:192633%2B