android / android/android-test

Framework quitting unexpectedly

Offen
#536 0 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
1.2k
Forks
342
Ø Merge
11 Std. 29 Min.
Gemergte PRs (30 T.)
2

Beschreibung

### Description

Instrumentation testing is quitting unexpectedly, causing the testing suite to fail.
Sometimes it runs successfully from Android Studio UI, sometimes it doesn't. Same happens when using `./gradlew connectedCheck --no-parallel` from command-line.

`Min SDK: 23`
`Target SDK: 29`

The only test I have:
```kotlin
@SmallTest
@RunWith(AndroidJUnit4::class)
class HelloWorldTest {

@Test
fun testHelloWorld() {
val str = "Hello World"

assert(str == "Hello World")
}
}
```

From the Pixel 3 emulator running API 29 with Play-store it never succeeds and there's a logcat with the following:

```
2020-02-27 16:25:57.963 31404-31404/? E/AndroidRuntime: FATAL EXCEPTION: main
PID: 31404
java.lang.IllegalStateException: Call to getContentProviderExternal for: androidx_test_services.speak_easy returns null!
at androidx.test.services.speakeasy.client.ToolConnection$ToolConnectionPostIcs.doCall(ToolConnection.java:165)
at androidx.test.services.speakeasy.client.ToolConnection.publish(ToolConnection.java:79)
at androidx.test.services.speakeasy.client.ToolConnection.publish(ToolConnection.java:69)
at androidx.test.services.shellexecutor.BlockingPublish.getResult(BlockingPublish.java:74)
at androidx.test.services.shellexecutor.ShellCommandExecutorServer.start(ShellCommandExecutorServer.java:80)
at androidx.test.services.shellexecutor.ShellMain.main(ShellMain.java:45)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:338)
2020-02-27 16:25:57.963 31404-31404/? E/AndroidRuntime: Error reporting crash
java.lang.RuntimeException: Bad file descriptor
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:510)
at android.app.IActivityManager$Stub$Proxy.handleApplicationCrash(IActivityManager.java:4653)
at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:145)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1073)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.Thread.dispatchUncaughtException(Thread.java:2187)
```

From Pixel 2 API 28 emulator, and Pixel 2XL API 29 (no-playstore) emulator, it's intermittent.
Here's the full logcat: https://pastebin.com/1CvdmRaC

Also sometimes my test passes but `ConnectedTest` fails with `No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).` therefore failing the whole test run.

My app is split between 5 modules:
- 2 libraries
- 1 application
- 2 dynamic-features

The test is located in `app/src/androidTest/java//HelloWorldTest.kt`

I have configured my `build.gradle` per the documentation, on App and Dynamic Feature modules.
```kotlin
defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments = mapOf(
"clearPackageData" to "true"
)
}

useLibrary("android.test.runner")
useLibrary("android.test.base")
useLibrary("android.test.mock")

testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
}
```

Also configured all `AndroidManifest.xml`:
```xml

```
My dependencies:
```kotlin
object Versions {
const val test = "1.3.0-alpha04"
const val androidJUnit = "1.1.2-alpha04"
const val espresso = "3.3.0-alpha04"
}
object Test {
const val runner = "androidx.test:runner:${Versions.test}"
const val rules = "androidx.test:rules:${Versions.test}"
const val core = "androidx.test:core:${Versions.test}"
const val orchestrator = "androidx.test:orchestrator:${Versions.test}"
const val androidJUnit = "androidx.test.ext:junit:${Versions.androidJUnit}"
const val espresso = "androidx.test.espresso:espresso-core:${Versions.testEspressoCore}"
}
```

All modules (including libraries) are implementing these dependencies:
```kotlin
androidTestImplementation(Dependencies.test.core)
androidTestImplementation(Dependencies.test.runner)
androidTestImplementation(Dependencies.test.espresso)
androidTestImplementation(Dependencies.test.rules)
androidTestImplementation(Dependencies.test.androidJUnit)
androidTestUtil(Dependencies.test.orchestrator)
```

Android Studio version (and gradle plugin version) is `3.6.0`

### Steps to Reproduce

Run the test from Android Studio or run `./gradlew connectedCheck --no-parallel`

### Expected Results

Test should run successfully.

### Actual Results

Test are failing intermittently.

### AndroidX Test and Android OS Versions

AndroidX Test version `1.3.0-alpha04` (also tested with `1.1.0` and `1.2.0`).
Android OS Versions `P` and `Q`.

### Link to a public git repo demonstrating the problem:

Can't disclose code.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Führen Sie zunächst ./gradlew connectedCheck --no-parallel oder den Instrumentationstest aus Android Studio auf den aufgelisteten Pixel-Emulatoren aus und untersuchen Sie anschließend logcat auf den androidx_test_services.speak_easy-Fehler. Der Einstiegspunkt des Tests ist app/src/androidTest/java//HelloWorldTest.kt, die Konfiguration befindet sich in den app- und dynamic-feature-build.gradle-Dateien. Als erledigt gilt die Aufgabe, wenn die Instrumentation-Suite zuverlässig ausgeführt wird und ConnectedTest den Test entdeckt und abschließt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, kotlin
Bereich
mobile, testing
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.