-1

I am new to Unit test and Mockito. I am trying to write unit test for the below firebase call. Can anyone help me that how to write unit test for FirebaseMessaging using Mockito. Thanks

 fun unsubscribeEventVoucherTopic(String topic) {
    
   FirebaseMessaging.getInstance().unsubscribeFromTopic(topic).addOnCompleteListener { task ->
      val msg = "unsubscribe $topic success: ${task.isSuccessful}"
      Log.d(TAG, "unsubscribeEventVoucherTopic: $msg")
    }
}
Jayashri
  • 1
  • 1

1 Answers1

0

Reread what unit tests are please. They shouldn't be used in a code that has possible requests/algoritms that can depend of not only your code but exterior cases (per example: internet request depends if the device has internet, therefore, the unit test won't be accurate).

To make a unit test, you should give default data and verify what your code will do with it.