意式浓咖啡测试以显示通知 [英] Espresso test for Notification to showing up

查看:77
本文介绍了意式浓咖啡测试以显示通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想测试一下,当我收到推送时,会显示通知.并且最好检查其属性(例如标题,设置意图等).

我该怎么办?

 @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

更多信息:

还访问: 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:

Visit also: Android Testing: UIAutomator vs Espresso

这篇关于意式浓咖啡测试以显示通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆