簡體   English   中英

在Android中使用Espresso測試錯誤

[英]Testing with Espresso in Android error

我正在與意式濃縮咖啡進行測試。 我正在關注意式濃縮咖啡

當我嘗試像這個網站一樣工作時發生了問題。 首先是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);

請幫忙!!!

Android Studio在“用戶”和“系統”處顯示錯誤。 我不明白這個錯誤是什么意思。

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

我沒有看到該測試類的任何日志或完整代碼,因此我只能建議您檢查此示例

在這里,您可以在一個文件中找到要查找的所有方法。

另請訪問Google Samples-Espresso Testing存儲庫

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM