I'm trying to understand how functional tests work in android applications. But I have difficulties. In the case shown below, I check in database if there are any "work" in the database and if this exists, it goes to the WorkActivity activity, otherwise it goes to CalendarActivity.
MainActivity
public void btnNotes(View view) {
if (userDAO.existWork() == false) {
Intent intentRegisterWork = new Intent(this, WorkActivity.class);
startActivity(intentRegisterWork);
} else {
Intent intent = new Intent(this, CalendarActivity.class);
startActivity(intent);
}
MainActivityTest
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Rule
public ActivityTestRule<MainActivity> mMainActivityTestRule =
new ActivityTestRule<MainActivity>(MainActivity.class);
@Test
public void testChangeIntent() {
onView(withId(R.id.btnNotes));
Intent intent = new Intent (mMainActivityTestRule.getActivity(),WorkActivity.class);
mMainActivityTestRule.launchActivity(intent);
}
}
Any suggestions how do I test this?
Aucun commentaire:
Enregistrer un commentaire