android / android/android-test

Framework quitting unexpectedly

Aperta
#536 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
1.2k
Fork
342
Merge medio
11h 29m
PR unite (30g)
2

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia eseguendo ./gradlew connectedCheck --no-parallel o il test di instrumentation da Android Studio sugli emulatori Pixel elencati, quindi esamina logcat per individuare l'errore androidx_test_services.speak_easy. Il punto di ingresso del test è app/src/androidTest/java//HelloWorldTest.kt, con la configurazione nei file build.gradle di app e dynamic-feature. Il lavoro è completato quando la suite di instrumentation viene eseguita in modo affidabile e ConnectedTest rileva e completa il test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, kotlin
Ambito
mobile, testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.