Espresso Test for Notification of Appearance

I want to check that when I receive a push, a notification will appear. And it could also be to check its properties (e.g. name, set intent, etc.)

How can i do this?

 @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?
}
+4
source share
1 answer

In a test environment, the Espresso UI no longer displays the actual view. I seriously doubt that you can check any notice with Espresso.

To do this, use a different Google testing framework uiautomator, which is described as:

UI Automator - , .

, Espresso: http://qathread.blogspot.com/2015/05/espresso-uiautomator-perfect-tandem.html

:

: Android-: UIAutomator vs Espresso

+9

Source: https://habr.com/ru/post/1621746/


All Articles