I am struggling with espresso testing where I am trying to test a button click but unable to understand how. I am new to Espresso testing and have searched all over internet/youtube but can not find exact solution.
here's the problem:
onView(withId(R.id.myButton)).perform(click()).check(Navigation.findNavController(<requireView() is not recognized>).popBackStack()); hence don't know what will come there. My goal is to just check if button click performs popBackStack. If my entire approach is also wrong please tell me, how do I proceed.
@RunWith(AndroidJUnit4.class)
public class MyTestClass {
public FragmentScenario<MyFragment> fragmentScenario;
@Before
public void setUp(){
fragmentScenario =FragmentScenario.launchInContainer(MyFragment.class);
fragmentScenario.moveToState(Lifecycle.State.STARTED);
}
@Test
public void testButton() {
onView(withId(R.id.myButton)).perform(click()).check(Navigation.findNavController(<requireView() is not recognized>).popBackStack()); hence don't know what will come there.
}
}