You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Asserting on activity result extra from ActivityScenario results in exception. This was not the case with ActivityTestRule.
Steps to Reproduce
Start "picker" activity with scenario = ActivityScenario.launch(intent)
Simulate result_ok with included parcelable extra
Assert on activity result intent extras (which triggers unmarshalling ClassNotFoundException exception) with
val activityResult = scenario.result!!
assertThat(activityResult, hasResultCode(RESULT_OK))
assertThat(activityResult, hasResultData(hasExtraWithKey(KEY_SELECTED_CITY)))
Expected Results
Assertion works
Actual Results
Exception similar to next one:
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: my.package.ParcelableAutoCompleteCity
at android.os.Parcel.readParcelableCreator(Parcel.java:3042)
at android.os.Parcel.readParcelable(Parcel.java:2964)
at android.os.Parcel.readValue(Parcel.java:2866)
at android.os.Parcel.readArrayMapInternal(Parcel.java:3244)
at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
at android.os.BaseBundle.unparcel(BaseBundle.java:236)
at android.os.BaseBundle.keySet(BaseBundle.java:562)
at androidx.test.espresso.intent.matcher.BundleMatchers$BundleMatcher.matchesSafely(BundleMatchers.java:47)
at androidx.test.espresso.intent.matcher.BundleMatchers$BundleMatcher.matchesSafely(BundleMatchers.java:35)
at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:67)
at androidx.test.espresso.intent.matcher.IntentMatchers$7.matchesSafely(IntentMatchers.java:215)
at androidx.test.espresso.intent.matcher.IntentMatchers$7.matchesSafely(IntentMatchers.java:206)
at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:67)
at androidx.test.espresso.contrib.ActivityResultMatchers$1.matchesSafely(ActivityResultMatchers.java:46)
at androidx.test.espresso.contrib.ActivityResultMatchers$1.matchesSafely(ActivityResultMatchers.java:37)
at org.hamcrest.TypeSafeMatcher.matches(TypeSafeMatcher.java:67)
at androidx.test.espresso.matcher.ViewMatchers.assertThat(ViewMatchers.java:7)
at androidx.test.espresso.matcher.ViewMatchers.assertThat(ViewMatchers.java:5)
AndroidX Test and Android OS Versions
1.3.0 and sdk29
Link to a public git repo demonstrating the problem:
I need some guidance. I guess this repo should have already some tests which work on activity result verification. What are they? I would then extend them to include parcelable extra into activity result intent.
Current workaround
Set classloader explicitly before asserting result
val activityResult = scenario.result!!
activityResult.resultData.setExtrasClassLoader(this::class.java.classLoader)
assertThat(activityResult, hasResultCode(RESULT_OK))
assertThat(activityResult, hasResultData(hasExtraWithKey(KEY_SELECTED_CITY)))
The text was updated successfully, but these errors were encountered:
Description
Asserting on activity result extra from
ActivityScenario
results in exception. This was not the case withActivityTestRule
.Steps to Reproduce
scenario = ActivityScenario.launch(intent)
Expected Results
Assertion works
Actual Results
Exception similar to next one:
AndroidX Test and Android OS Versions
1.3.0 and sdk29
Link to a public git repo demonstrating the problem:
I need some guidance. I guess this repo should have already some tests which work on activity result verification. What are they? I would then extend them to include parcelable extra into activity result intent.
Current workaround
Set classloader explicitly before asserting result
The text was updated successfully, but these errors were encountered: