android / android/android-test

Framework quitting unexpectedly

Open
#536 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

Research direction

Start by running ./gradlew connectedCheck --no-parallel or the instrumentation test from Android Studio on the listed Pixel emulators, then inspect logcat for the androidx_test_services.speak_easy failure. The test entry point is app/src/androidTest/java//HelloWorldTest.kt, with configuration in the app and dynamic-feature build.gradle files. Done means the instrumentation suite runs reliably and ConnectedTest discovers and completes the test.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.