2016-07-31 46 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;