package ; import android.support.test.espresso.intent.rule.IntentsTestRule; import android.support.test.runner.AndroidJUnit4; import android.test.suitebuilder.annotation.LargeTest; import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import static android.support.test.espresso.intent.Intents.intended; import static android.support.test.espresso.intent.matcher.ComponentNameMatchers.hasShortClassName; import static android.support.test.espresso.intent.matcher.IntentMatchers.hasComponent; import static org.junit.Assert.assertNotNull; @RunWith( AndroidJUnit4.class ) @LargeTest public class BeforeLoginActivityTest { private static final String TEST_EMAIL = "annyce@mycompany.com"; private static final String TEST_PASSWORD = "123456"; private static final String PACKAGE_NAME = "my.package"; @Rule public IntentsTestRule activityRule = new IntentsTestRule<>( LoginActivity.class ); @Test public void shouldProceedLoginWhenValid () { onView( withId( R.id.login_username_entry ) ).perform( typeText( TEST_EMAIL ) ); onView( withId( R.id.login_password_entry ) ).perform( typeText( TEST_PASSWORD ) ); onView( withId( R.id.login_button ) ).perform( click() ); intended( hasComponent( hasShortClassName( PACKAGE_NAME ) ) ); } }