❓ Questions and Help
Android Espresso not able to test fragement
I am trying to launch a fragment as below
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_home, menu)
menuNotification.icon = NotificationHelper.getNotificationDrawable(UserPool.userId )
What have you tried?
private lateinit var homeFragmentScenario: FragmentScenario
@MockK
lateinit var mockPool: UserPool
@before
fun setUp() {
InjectMocksRule.createMockK(this)
ActivityScenario.launch(MainActivity::class.java)
homeFragmentScenario= launchFragmentInContainer(themeResId = R.style.AppTheme)
homeFragmentScenario.moveToState(Lifecycle.State.STARTED)
Intents.init()
}
fun loadScreen() {
every { mockPool.userId } answers {"123456"}
Espresso.onView(ViewMatchers.withId(R.id.layout_home))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}
❓ Questions and Help
Android Espresso not able to test fragement
I am trying to launch a fragment as below
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_home, menu)
What have you tried?
private lateinit var homeFragmentScenario: FragmentScenario
@before
fun setUp() {
InjectMocksRule.createMockK(this)
ActivityScenario.launch(MainActivity::class.java)
homeFragmentScenario= launchFragmentInContainer(themeResId = R.style.AppTheme)
homeFragmentScenario.moveToState(Lifecycle.State.STARTED)
Intents.init()
}
fun loadScreen() {
every { mockPool.userId } answers {"123456"}
Espresso.onView(ViewMatchers.withId(R.id.layout_home))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}