When I click the run test button, Android Studio builds and attempts to run the test.
70% of the time, it says "Instantiating tests..." and never goes anywhere from there. If I kill the adb-server, unplug adevice, or kill an emulator, the test suite magically runs fine.
I even saw a bizarre behavior the other night. I unplugged the device while it said Instantiating Tests. Android Studio picked up that it disappeared. I pulled my phone out of my pocket a few hours later, unlocked it, and out of nowhere, it started running the test suite.
Any idea what can cause this behavior? The closest I've found is Android Test stopping in instantiating tests, but that is referring to a different issue.
The test runner handles loading your test package and the app under test to a device, running your tests, and reporting test results. This test runner supports several common testing tasks, including the following: Writing JUnit tests. Accessing the app's context. Filtering tests.
A typical project in Android Studio contains two directories in which you place tests. The androidTest directory should contain the tests that run on real or virtual devices. Such tests include integration tests, end-to-end tests, and other tests where the JVM alone cannot validate your app's functionality.
The suite is built using the Android testing framework. The runner is implemented as a single instrumentation test that executes the test package and parses the result log. The logs are taken directly from the device (logcat).
Unit tests or small tests only verify a very small portion of the app, such as a method or class. End-to-end tests or big tests verify larger parts of the app at the same time, such as a whole screen or user flow.
I had the same, issue would only occur when running as debug though. Never had it when running normally.
I fixed it by removing Test Orchestrator in my Build.gradle.
//Disable Me // testInstrumentationRunnerArguments clearPackageData: 'true' // testOptions { // execution 'ANDROID_TEST_ORCHESTRATOR' // }
This happened to me on my OnePlus 5
as well - I couldn't make it running. Seems like it's related to this device only.
I end up using an emulator and other phones, which works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With