Issue
Espresso testing is working well but when trying to check if the toast message appeared, using this code
onView(withText(R.string.added_successfully_msg)).inRoot(toastMatcher())
.check(matches(withText(R.string.added_successfully_msg)));
or this one
onView(withText(R.string.added_successfully_msg)).inRoot(withDecorView(not(activity.getWindow().getDecorView()))).check(matches(isDisplayed()));
this exception is thrown
java.lang.IncompatibleClassChangeError: Class 'org.hamcrest.StringDescription' does not implement interface 'java.lang.Iterable' in call to 'java.util.Iterator java.lang.Iterable.iterator()' (declaration of 'org.hamcrest.BaseDescription' appears in /data/app/my package name.test-7NCoDq2dIYza4GpnMXXGhQ==/base.apk)
at org.hamcrest.BaseDescription.appendValueList(BaseDescription.java:81)
at androidx.test.espresso.matcher.BoundedDiagnosingMatcher.describeTo(BoundedDiagnosingMatcher.java:4)
at org.hamcrest.BaseDescription.appendDescriptionOf(BaseDescription.java:24)
at org.hamcrest.StringDescription.toString(StringDescription.java:28)
at org.hamcrest.BaseMatcher.toString(BaseMatcher.java:26)
at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2978)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2855)
at java.util.Formatter.format(Formatter.java:2524)
at java.util.Formatter.format(Formatter.java:2459)
at java.lang.String.format(String.java:2911)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:12)
at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
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)
testing dependency
testImplementation 'androidx.test:monitor:1.5.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-core:3.12.4"
// Core library
androidTestImplementation 'androidx.test:core:1.4.0'
// AndroidJUnitRunner and JUnit Rules
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.1-alpha06'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
// Espresso dependencies
def espressoVersion = "3.5.0-alpha06"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation ("androidx.test.espresso:espresso-contrib:$espressoVersion"){exclude module: 'protobuf-lite'}
androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
I think this exception is thrown when I use withText()
but I can't find a solution.
thanks for help
Solution
I just encountered this as well. I think it might be a bug in espresso 3.5.0-alpha06 - it works again if I revert to 3.5.0-alpha04
I haven't found a bug filed with google yet, but it may be worth doing.
It's possible it's a conflict with another library that is incompatible, but I couldn't identify the exact cause yet.
Update: It seems be solved in the last update 3.5.0-alpha07
Answered By - konakid
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.