Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Accessibility checks causing Espresso test run failures #5435

Open
adhiamboperes opened this issue Jun 20, 2024 · 2 comments
Open

[BUG]: Accessibility checks causing Espresso test run failures #5435

adhiamboperes opened this issue Jun 20, 2024 · 2 comments
Labels
bug End user-perceivable behaviors which are not desirable. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.

Comments

@adhiamboperes
Copy link
Collaborator

Describe the bug

With recent dependency updates project wide, there is an issue running Espresso tests, causing tests not to run.

Steps To Reproduce

Run any test on an emulator, such as the SplashActivityTest tests.

Expected Behavior

Tests should run and show the outcome of an assertion.

Screenshots/Videos

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager;
at com.google.android.apps.common.testing.accessibility.framework.SpeakableTextPresentViewCheck.<clinit>(SpeakableTextPresentViewCheck.java:42)
at com.google.android.apps.common.testing.accessibility.framework.AccessibilityCheckPreset.getViewChecksForPreset(AccessibilityCheckPreset.java:59)
at com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityValidator.<init>(AccessibilityValidator.java:50)
at androidx.test.espresso.accessibility.AccessibilityChecks.<clinit>(AccessibilityChecks.java:37)
at androidx.test.espresso.accessibility.AccessibilityChecks.enable(AccessibilityChecks.java:84)
at org.oppia.android.testing.OppiaTestRule$apply$1.evaluate(OppiaTestRule.kt:34)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.oppia.android.testing.junit.ParameterizedAutoAndroidTestRunner.run(ParameterizedAutoAndroidTestRunner.kt:105)
at org.oppia.android.testing.junit.OppiaParameterizedTestRunner$ProxyParameterizedTestRunner.run(OppiaParameterizedTestRunner.kt:287)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)

What device/emulator are you using?

No response

Which Android version is your device/emulator running?

API 29

Which version of the Oppia Android app are you using?

No response

Additional Context

You can work around this issue by anniotating a specific test function with @DisableAccessibilityChecks.

Some tests involving Dataproviders fail with exception:

org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface androidx.lifecycle.Observer.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.



IMPORTANT INFORMATION FOR ANDROID USERS:

The regular Byte Buddy mock makers cannot generate code on an Android VM!
To resolve this, please use the 'mockito-android' dependency for your application:
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22

Java               : 0.9
JVM vendor name    : The Android Project
JVM vendor version : 2.1.0
JVM name           : Dalvik
JVM version        : 0.9
JVM info           : null
OS name            : Linux
OS version         : 4.14.175-gd7103c943974-dirty


Underlying exception : org.mockito.exceptions.base.MockitoException:
Could not look up implicit location for storing generated classes

You can configure an explicit location by setting the system property
'org.mockito.android.target' to a folder for storing generated class files
This location must be in private scope for most API versions, for example:

MyActivity.this.getDir("target", Context.MODE_PRIVATE)
or
getInstrumentation().getTargetContext().getCacheDir().getPath()
at org.oppia.android.testing.data.DataProviderTestMonitor$mockObserver$2.invoke(DataProviderTestMonitor.kt:255)
at org.oppia.android.testing.data.DataProviderTestMonitor$mockObserver$2.invoke(DataProviderTestMonitor.kt:44)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.oppia.android.testing.data.DataProviderTestMonitor.getMockObserver(DataProviderTestMonitor.kt:44)
at org.oppia.android.testing.data.DataProviderTestMonitor.startObservingDataProvider$lambda-0(DataProviderTestMonitor.kt:97)
at org.oppia.android.testing.data.DataProviderTestMonitor.lambda$2T4xClYy8HQy387izRjLg9w5AJE(Unknown Source:0)
at org.oppia.android.testing.data.-$$Lambda$DataProviderTestMonitor$2T4xClYy8HQy387izRjLg9w5AJE.run(Unknown Source:2)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:2207)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: org.mockito.exceptions.base.MockitoException:
Could not look up implicit location for storing generated classes

You can configure an explicit location by setting the system property
'org.mockito.android.target' to a folder for storing generated class files
This location must be in private scope for most API versions, for example:

MyActivity.this.getDir("target", Context.MODE_PRIVATE)
or
getInstrumentation().getTargetContext().getCacheDir().getPath()
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355)
... 17 more
@adhiamboperes adhiamboperes added bug End user-perceivable behaviors which are not desirable. triage needed Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet. and removed triage needed labels Jun 20, 2024
@theMr17
Copy link
Collaborator

theMr17 commented Jul 17, 2024

Tried checking out some dependency update PRs. Found that the bug was introduced while bumping Kotlin to v1.6.10 in #4937.

@adhiamboperes
Copy link
Collaborator Author

Related: android/android-test#999 (comment)

BenHenning added a commit that referenced this issue Jul 23, 2024
This upgrades the AndroidX Espresso Accessibility package to version
3.2.0 in an attempt to fix #5435.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: High High perceived user impact (breaks a critical feature or blocks a release). Work: Medium The means to find the solution is clear, but it isn't at good-first-issue level yet.
Development

No branches or pull requests

2 participants