Как проверить намерение из фрагмента в Robolectri c 4 со сценарием фрагмента, когда FragmentA в ActivityA должен открыть ActivityB. Цель всегда равна нулю.
@Test
fun testListFragment() {
val args = Bundle()
val scenario = launchFragmentInContainer<MovieListFragment>(args)
scenario.onFragment { fragment ->
val rvMovies = fragment.view?.findViewById<RecyclerView>(R.id.rvMovies)
rvMovies?.getChildAt(0)?.performClick()
val expectedIntent = Intent(fragment.requireActivity(), MovieDetailActivity::class.java)
val actualIntent = (shadowOf(fragment.requireActivity()) as ShadowActivity).nextStartedActivity // actualIntent always return null
assertNotNull(expectedIntent)
assertNotNull(actualIntent)
assertTrue(expectedIntent.filterEquals(actualIntent))
}
scenario.recreate()
}