This is the shortest variant of the test:
…
@RunWith(AndroidJUnit4.class)
@LargeTest
public class RunAllTest {
@Test
public void testShortRun() {
Context ctx = ApplicationProvider.getApplicationContext();
Intent intent = new Intent(ctx, SplashActivity.class);
ActivityScenario activityScenario = ActivityScenario.launch(intent);
}
}
It throws an exception:
java.lang.AssertionError: Activity never becomes requested state "[RESUMED, DESTROYED, STARTED, CREATED]" (last lifecycle transition = "PRE_ON_CREATE”)
Mobile phone model: Xiaomi Redmi 9
MIUI version: MIUI Global 11.0.7 Stable 11.0.7.0(QJCRUXM)
Android version: 10 QP1A.190711.020
Android security patch level: 2020-09-01
Founded solution/workaround:
you should disable (enabled by default)
Settings -> Additional settings -> Developer options -> Turn on MIUI optimization