lundi 1 août 2016

Instrumental tests - null pointer exception on setContentView()

I have an instrumental test located at app/androidTest/java/myapp. I have one simple test method in there:

public class LoginActivityTest {

    private static final String EMAIL = "admin@gmail.com";
    private static final String PASSWORD = "admin";

    @Rule
    public IntentsTestRule<LoginActivity> loginActivity = new IntentsTestRule<>(LoginActivity.class);

    @Test
    public void LoginWithProperCredentials() {
        onView(withId(R.id.email_textView))
                .perform(typeText(EMAIL));
        onView(withId(R.id.password_login))
                .perform(typeText(PASSWORD));
        onView(withId(R.id.email_sign_in_button))
                .perform(click());

        intended(allOf(
                hasExtra(GeneralConstants.AUTHENTICATED, true),
                hasExtra(GeneralConstants.TOKEN, isA(String.class)),
                toPackage("myapp")));
    }
}

I have upgraded Android Support Repository, added neccessary androidTestCompile dependencies as well as default testInstrumentationRunner ("android.support.test.runner.AndroidJUnitRunner") and I've chosen Android Instrumentation Tests as Build Variant. Yet, attempting to launch the test gives me ResourceNotFoundException. I've figured out, that it's the setContentView() method in onCreate(Bundle bundle) that throws this Exception.

I'm being struggling with this for a while now. What could be the reason for it?

Aucun commentaire:

Enregistrer un commentaire