I am getting weird issue when running on my unit test. I have this function
internal fun getPendingStatusAction(
status: XYZ
): (() -> Unit)? {
var action: (() -> Unit)? = null
this.yo = yo
if (isAwaitingIdVerification(status)) {
action = {
router.xyz()
}
} else if (status == XYZ.PURCHASE) {
action = {
router.xyz()
}
}
return action
}
When I run single unit test it complete fine, but when I run whole file unit test it failed.
@Test
fun `getPendingStatusAction - `() {
// STUBBING
val mockStatus = XYZ.VERIFICATION
every { subject.isAwaitingIdVerification(any()) } returns true
// EXECUTION
val action = subject.getPendingStatusAction(mockStatus)
action?.invoke()
// VERIFICATION
verify {
router.xyz()
}
}
ERROR
Verification failed: call 1 of 2: Router(mockRouter#172).xyz()) was not called
java.lang.AssertionError: Verification failed: call 1 of 2: Router(mockRouter#172).xyz()) was not called