I am developing a backend service that sends push notifications to mobile apps via either FCM or APNS. I would like to create an automated test that can run in under a minute and validates that the server can successfully send a notification. Note that I do not necessarily need to check that the notification has been delivered, just that FCM or APNS has successfully processed the request to send the message.
I know that theoretically I could automate this test using a tool like appium and use test hooks to retrieve a registration/device token from the app, but it seems cumbersome to use appium to test if the backend can send a message. I have also tried to use a hard coded registration token, but registration and device tokens are prone to rotate, so the test could suddenly stop passing. Are there any other options?
First of all, I would think about what scenario do we want to cover.
200
. As a result, you may use usual integration test that will call Firebase API and check the success code (200
) and error field (MissingRegistration / InvalidRegistration / NotRegistered
), and if you get such a pair - your request was succesfull. There is no much need to test it with a correct user device token, because if everything else is correct, the result will be the same (but actually delivered to a phone).
Firebase docs
Appium is automation framework for black-box testing, so in your case, it allows to check if the notification pops up on a device. And that's it.
Appium has no access to your application code, you can send adb
commands via it, but basically, no way to play with tokens until you expose it to the UI layer of your app.
Moreover, Appium is not supported by Firebase.
I suggest looking into Espresso, where you write tests with direct access to your application code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With