2015-10-19 47 views
1

我正在使用espresso進行測試。我正在關注Espresso Intents在Android中使用Espresso進行測試錯誤

當我嘗試像本網站一樣工作時發生問題。首先是validateIntentSentToPackage方法:

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

Android Studio在「用戶」和「系統」上顯示錯誤。我不明白這個錯誤是什麼意思。

二是activityResult_IsHandledProperly方法:

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中顯示錯誤顯示java.lang.NullPointerException和線intending(toPackage("com.example.unittestdemo")).respondWith(result);

請幫助!

回答

1

Android Studio在「用戶」和「系統」上顯示錯誤。我不明白這個錯誤是什麼意思。

我想,你以前沒有聲明過這些變量。

我沒有看到任何記錄或該測試類的整個代碼,所以我只能建議你檢查這個example

在這裏,你會發現,你要在一個文件中尋找所有的方法。

也請訪問Google Samples - Espresso Testing repository

相關問題