什么是Android Espresso包`android.support.test.espresso.intent`的依赖?

时间:2015-07-22 23:39:47

标签: android testing android-intent dependencies android-espresso

我遇到了一个有趣的包,其中特别包含用于测试Intent发送的Intents类,以及IntentMatchers类,因为Intents类页面上列出的代码段显示:

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

// Set up result stubbing when an intent sent to "contacts" is seen.
intending(toPackage("com.android.contacts")).respondWith(result));

但是当我开始尝试时,Android Studio抱怨不知道这些课程。我检查了android-test-kit website上列出的Espresso罐子(espresso-core和espreso-contrib),实际上我在这些罐子里找不到任何android.support.test.espresso.intent包裹。我缺少任何依赖吗?

1 个答案:

答案 0 :(得分:4)

您还需要

androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2'

有关详细信息,请参阅https://code.google.com/p/android-test-kit/wiki/EspressoIntentsSetupInstructions