Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Espresso not able to test fragement #75

Open
AbhishekArrk opened this issue Aug 20, 2022 · 0 comments
Open

Android Espresso not able to test fragement #75

AbhishekArrk opened this issue Aug 20, 2022 · 0 comments
Labels
question Further information is requested

Comments

@AbhishekArrk
Copy link

AbhishekArrk commented Aug 20, 2022

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

@AbhishekArrk AbhishekArrk added the question Further information is requested label Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant