mardi 4 août 2015

Android Unit Test: NotificationServiceListener doesn't work when app is tested with ActivityInstrumentationCase2

I am trying to write tests to check the behaviour of ongoing notifications, and for this reason i decided to extend NotificationServiceListener to get information about notifications. I used the kpbird example (http://ift.tt/MK5vAG).

When i run the application in normal mode, the service appears to be working. However, when i try to run a test case to do the same instructions with robotium commands, the service doesn't appear to be responding (the log messages put inside onNotificationReceived() and onNotificationRemoved() are not appearing in debug screen).

One thing in kpbird example i found odd, was the lack of service launch instructions, but because the service responded and appeared to be working, i just assume, that it is just the way the NotificationServiceListener works.

Other thing i noticed was, that when app was launched normally, only the onNotificationReceived() and noNotificationRemoved() functions are being called. However, when i run the test, i also get service's onCreate() called before the I/TestRunner: started message.

I tried to manually launch the service from test case, but still got no responses from it.

So i am wondering, is there any reason, why the service is acting odd when app is being tested?

Aucun commentaire:

Enregistrer un commentaire