I have a class that I recently converted from java to kotlin and now one of my unit tests is failing to compile.
This is line that is causing it:
mockkStatic(PhoneNumberSelectionActivity::class)
every {
PhoneNumberSelectionActivity.startActivity(
mockActivity,
any(),
any()
)
} returns Unit
My stack trace:
Failed matching mocking signature for SignedCall(retValue=java.lang.Void@7a5aa8c5, isRetValueMock=false, retType=class java.lang.Void, self=TNActivityBase(mockActivity#1), method=startActivity(Intent), args=[null], invocationStr=TNActivityBase(mockActivity#1).startActivity(null)) left matchers: [any(), any()]
io.mockk.MockKException: Failed matching mocking signature for SignedCall(retValue=java.lang.Void@7a5aa8c5, isRetValueMock=false, retType=class java.lang.Void, self=TNActivityBase(mockActivity#1), method=startActivity(Intent), args=[null], invocationStr=TNActivityBase(mockActivity#1).startActivity(null)) left matchers: [any(), any()]
The class PhoneNumberSelectionActivity inherits from TNActivityBase.
Here is the function that we are trying to mock in PhoneNumberSelectionActivity:
fun startActivity(
host: Activity,
phoneExpired: Boolean,
@ACTIVITY_HOST_TYPE activityHostType: Int
) {
if (sIsRunning) {
return
}
sIsRunning = true
val intent = Intent(host, PhoneNumberSelectionActivity::class.java)
intent.putExtra(EXTRA_ACTIVITY_HOST_TYPE, activityHostType)
if (phoneExpired) {
intent.putExtra(EXTRA_SHOW_PHONE_EXPIRE_DIALOG, true)
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK)
host.startActivity(intent)
}
It seems to me that mockkStatic is not doing its job. Thoughts?