Unit-Test, sendSignInLinkToEmail(...) darf nicht null sein
Posted: 13 Jan 2025, 08:03
Ich versuche, einen Erfolgsfall für einen Unit-Test für die passwortlose Anmeldung bei Firebase zu schreiben, erhalte jedoch eine Nullzeiger-Ausnahme und den Fehler, dass sendSignInLinkToEmail(...) nicht null sein darf.
`@Mock
private lateinit var firebaseAuth: FirebaseAuth
Ich erwarte „Response.Success“ in „assurance.Equals“, erhalte aber „Response.Error“ aufgrund dieser Nullzeigerausnahme ](https://stackoverflow.com)
`@Mock
private lateinit var firebaseAuth: FirebaseAuth
Code: Select all
@InjectMocks
private lateinit var passwordLessSignInRepo: PasswordLessSignInRepo
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
}
val taskVoid: Task = mock()
whenever(taskVoid.isSuccessful).thenReturn(true)
whenever(firebaseAuth.sendSignInLinkToEmail("example@gmail.com", actionCodeSettings)).thenReturn(taskVoid)
val result = passwordLessSignInRepo.sendSignInLink("example@gmail.com")
assertEquals(Response.SUCCESS, result.response)`