freewym / freewym/espresso

Android Espresso not able to test fragement

Open
#75 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
939
Forks
116
PR merge metrics
No merged PRs in 30d

Description

## ❓ 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()

}

@Test
fun loadScreen() {
every { mockPool.userId } answers {"123456"}
Espresso.onView(ViewMatchers.withId(R.id.layout_home))
.check(ViewAssertions.matches(ViewMatchers.isDisplayed()))
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.