Espresso accessibility checks no longer catching obvious failures

32 Views Asked by At

I have written a basic UI test with Espresso that launches the activity and confirms a specific view is visible on the activity. I turned on accessibility checking via this code (which works and finds some accessibility failures on other activities):

class SampleAccessibilityTest {
    init {
        AccessibilityChecks.enable()
            .setRunChecksFromRootView(true)
    }

I intentionally added two new buttons to my activity that should fail several accessibility checks. They should fail for overlapping (DuplicateClickableBoundsViewCheck), one button for being too small (TouchTargetSizeViewCheck), and for bad contrast (TextContrastCheck, black on dark purple).

<Button
    android:id="@+id/buttonLowContrast"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:contentDescription="A button to fail accessibility checks"
    android:text="Low Contrast Text"
    android:textColor="@color/black"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/button" />

<Button
    android:id="@+id/buttonLowContrast2"
    android:layout_width="12dp"
    android:layout_height="12dp"
    android:contentDescription="A button to fail accessibility checks"
    android:text="Overlap"
    android:textColor="@color/black"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/button" />

Yet when I run the test that views these buttons, I get zero accessibility failures. There should be three!

0

There are 0 best solutions below