Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save husaynhakeem/895e55b3a6d213d4401eb5f5e7661b36 to your computer and use it in GitHub Desktop.
Save husaynhakeem/895e55b3a6d213d4401eb5f5e7661b36 to your computer and use it in GitHub Desktop.
@Test
fun shouldReceiveData() {
val scenario = FragmentScenario.launchInContainer(FragmentA::class.java)
// Pass data using the parent fragment manager
scenario.onFragment { fragment ->
val data = bundleOf(KEY_DATA to "value")
fragment.parentFragmentManager.setFragmentResult("aKey", data)
}
// Verify data is received, for example, by verifying it's been displayed on the UI
onView(withId(R.id.textView)).check(matches(withText("value")))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment