android / android-test

An extensive framework for testing Android apps
https://android.github.io/android-test
Apache License 2.0
1.16k stars 309 forks source link

"Overslept and turned a tap into a long press" should immediately fail test #438

Open tir38 opened 5 years ago

tir38 commented 5 years ago

Description

We have a flaky test that is caused by Overslept and turned a tap into a long press

09-10 18:05:56.883: I/ViewInteraction(28516): Performing 'single click' action on view with id: com.example.debug:id/action_audio_settings
...
09-10 18:05:57.508: W/MotionEvents(28516): Overslept and turned a tap into a long press
...
09-10 18:05:57.654: E/TestRunner(28516): failed: somTest(com.example.SomeTestClass)
09-10 18:05:57.654: E/TestRunner(28516): ----- begin exception -----
09-10 18:05:57.656: E/TestRunner(28516): androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.example:id/some_view

The problem is that the single click turns into long click which does not correctly nav to next screen which then leads to no matching view.

Steps to Reproduce

Flaky test, not easily reproducible

Expected Results

Ideally the test should fail as soon as we enter an indeterminant state. If a tap gets converted to a long press at random then who knows where the rest of the test will lead.

This makes it very difficult to track the source of the failure. I would rather the test was flaky but failed at the source of the problem (system / espresso timing).

AndroidX Test and Android OS Versions

const val AndroidX_Junit = "androidx.test.ext:junit:1.1.1" const val AndroidX_TestRunner = "androidx.test:runner:1.2.0" const val AndroidX_TestRules = "androidx.test:rules:1.2.0" const val AndroidX_Test_Orchestrator = "androidx.test:orchestrator:1.2.0" private const val espressoVersion = "3.2.0" const val Espresso_Core = "androidx.test.espresso:espresso-core:$espressoVersion" const val Espresso_IdlingResource = "androidx.test.espresso:espresso-idling-resource:$espressoVersion" const val Espresso_Contrib = "androidx.test.espresso:espresso-contrib:$espressoVersion"

TarCV commented 5 years ago

I thought it is actually the expected behavior for click() (and the other overload without rollbackAction parameter) to immediately fail a test in this case. Am I wrong?

tir38 commented 4 years ago

It doesn't seem to be happening for me. The test is happy to chug along until something else fails.

sbolotovms commented 4 years ago

@tir38 Try running this test on Android x86 Emulator running API 29, I have the same "flaky" test which reproes on this config all the time.