意式浓咖啡测试以显示通知 [英] Espresso test for Notification to showing up
问题描述
我想测试一下,当我收到推送时,会显示通知.并且最好检查其属性(例如标题,设置意图等).
我该怎么办?
@Before
public void setupTest() {
mData.putString(PushNotificator.KEY_PUSH_TYPE, PushType.PROJECT_OFFER.toString());
mData.putString(PushNotificator.KEY_PUSH_OBJECT, pushObjectJsonString);
mContext = InstrumentationRegistry.getContext();
}
@Test
public void projectOfferCreatedFromBundle() {
mPushNotificator = new PushNotificator(mContext);
mPushNotificator.processPush(mData);
onView(withText("111")).check(matches(withText("111"))); //how to find notification?
}
Espresso UI测试框架所看到的并不比实际的视图多.我严重怀疑您是否可以使用Espresso查看任何通知.
为此,请使用另一个Google的测试框架uiautomator
,其描述为:
UI Automator是一个UI测试框架,适用于跨系统和已安装应用的跨应用功能UI测试.
在这里您将找到如何在Espresso中使用它: http ://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html
更多信息:- 文档(I): https://google.github.io/android-testing -support-library/docs/uiautomator/index.html
- 文档(II): http://developer.android.com/intl/es/training/testing/ui-testing/uiautomator-testing.html
还访问: Android测试:UIAutomator vs Espresso >
I want to test that when I receive push, Notification will be showing up. And it might be as well to check its properties (like title, set intent and so on.)
How can I do so?
@Before
public void setupTest() {
mData.putString(PushNotificator.KEY_PUSH_TYPE, PushType.PROJECT_OFFER.toString());
mData.putString(PushNotificator.KEY_PUSH_OBJECT, pushObjectJsonString);
mContext = InstrumentationRegistry.getContext();
}
@Test
public void projectOfferCreatedFromBundle() {
mPushNotificator = new PushNotificator(mContext);
mPushNotificator.processPush(mData);
onView(withText("111")).check(matches(withText("111"))); //how to find notification?
}
Espresso UI test framework doesn't see more than actual View. I doubt seriously that you can check any notification with Espresso.
For this purpose use another Googles testing framework uiautomator
, which is described as:
UI Automator is a UI testing framework suitable for cross-app functional UI testing across system and installed apps.
Here you would find how to use it with Espresso: http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html
More information:- Documentation(I): https://google.github.io/android-testing-support-library/docs/uiautomator/index.html
- Documentation(II): http://developer.android.com/intl/es/training/testing/ui-testing/uiautomator-testing.html
Visit also: Android Testing: UIAutomator vs Espresso
这篇关于意式浓咖啡测试以显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!