My app consists of one Activity
for many Fragments
.
I wish to use Espresso to test the UI of the Fragments
. However I ran into a p
Just show the Fragment using the Activity's SupportFragmentManager.
For example (Kotlin) with ActivityTestRule:
@Rule
@JvmField
var activityRule = ActivityTestRule(MainActivity::class.java)
Just do this before your tests:
@Before
fun setup() {
activityRule.activity.supportFragmentManager.beginTransaction().replace(R.id.main_activity_container_for_your_fragments, FragmentToShow(), "fragment-tag").commitAllowingStateLoss()
Thread.sleep(500)
}