I´m using:
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support:support-annotations:22.2.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
I have a LoginActivity that launch another activity after login call succeed, I need to test if the login succeed... So I thought that I can do it checking if the second activity (that should be launched) was launched.
@RunWith(AndroidJUnit4.class)
@LargeTest
public class CodeValidationTests {
@Rule
public ActivityTestRule<LoginActivity> mActivityRule =
new ActivityTestRule<>(LoginActivity.class);
@Test
public void validFieldSucceed() {
mockLogin();
onView(withId(R.id.text_login)).perform(typeText("asd"));
onView(withId(R.id.text_pwd)).perform(typeText("sss"));
onView(withId(R.id.button_login)).perform(ViewActions.click());
onView(withId(R.id.view_in_second_activity)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)));
}
}
Aucun commentaire:
Enregistrer un commentaire