dimanche 18 octobre 2015

Testing with Espresso in Android error

I'm working with espresso for testing. I'm following Espresso Intents

and problem happened when I try to work like this site. First is validateIntentSentToPackage method:

public void validateIntentSentToPackage() {
    user.clickOnView(system.getView(R.id.callButton));
    intended(toPackage("com.android.phone"));}

Android Studio display error at "user" and "system". I don't understand this error what does this mean.

Second is activityResult_IsHandledProperly method:

public void activityResult_IsHandledProperly() {
    Intent resultData = new Intent();
    String phoneNumber = "123-345-6789";
    resultData.putExtra("phone", phoneNumber);
    ActivityResult result = new ActivityResult(Activity.RESULT_OK, resultData);

    intending(toPackage("com.example.unittestdemo")).respondWith(result));
    onView(withId(R.id.pickButton)).perform(click());

    onView(withId(R.id.phoneNumber).check(matches(withText(phoneNumber)));}

Android Studio display error java.lang.NullPointerException and in line intending(toPackage("com.example.unittestdemo")).respondWith(result);

Please help!!!

Aucun commentaire:

Enregistrer un commentaire