2016-07-31 41 views
2

我正在學習如何使用Espresso進行UI測試,並且我想驗證意圖的狀態。 I'w寫的是這樣的:安卓咖啡 - 無法解析所有打算的方法

intended(allOf(
    hasAction(equalTo(Intent.ACTION_VIEW)), 
    hasCategories(hasItem(equalTo(Intent.CATEGORY_BROWSABLE))), 
    hasData(hasHost(equalTo("www.google.com"))), 
    hasExtras(allOf(
     hasEntry(equalTo("key1"), equalTo("value1")), 
     hasEntry(equalTo("key2"), equalTo("value2")))), 
     toPackage("com.android.browser"))); 

但它給了我compliation錯誤: enter image description here 這是從here的例子。這有什麼問題?

回答

2

您可以點擊這裏全樣本代碼:https://github.com/googlesamples/android-testing/blob/master/ui/espresso/IntentsBasicSample/app/src/androidTest/java/com/example/android/testing/espresso/BasicSample/DialerActivityTest.java

應與未來進口工作:

import static android.support.test.espresso.intent.Intents.intended; 
import static android.support.test.espresso.intent.matcher.BundleMatchers.hasEntry; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasAction; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasCategories; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasData; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.hasExtras; 
import static android.support.test.espresso.intent.matcher.IntentMatchers.toPackage; 
import static android.support.test.espresso.intent.matcher.UriMatchers.hasHost; 
import static org.hamcrest.Matchers.equalTo; 
import static org.hamcrest.Matchers.hasItem; 
import static org.hamcrest.core.AllOf.allOf;