When upgrading mockito-kotlin to any version after...
# test
m
When upgrading mockito-kotlin to any version after
6.1.0
, this function is now throwing an incomplete mock exception. I'm not sure if I'm doing something wrong that was just hidden by previous versions or if this is a regression in the library.
Copy code
fun createEmptyBitmap(
    width: Int = 10,
    height: Int = 10,
    density: Int = DisplayMetrics.DENSITY_DEFAULT,
    config: Bitmap.Config = Bitmap.Config.ARGB_8888
): Bitmap {
    val bytes by lazy {
        val offset = Random.nextInt()
        ByteArray(width * height * config.pixelSizeBytes) { (it + offset).toByte() }
    }
    return mock {
        on { getWidth() } doReturn width
        on { getHeight() } doReturn height
        on { getDensity() } doReturn density
        on { getConfig() } doReturn config
        on { byteCount } doReturn width * height * config.pixelSizeBytes
        on { copyPixelsToBuffer(any()) } doAnswer {
            val buffer = it.getArgument<ByteBuffer>(0)
            buffer.put(bytes)
            buffer.flip()
            Unit
        }
        on { compress(any(), any(), any()) } doAnswer { true }
    }
}
This is the Android
Bitmap
class. I assume it is related to the functions being final, but I thought mockito handles that now. The version of mockito itself did not seem to change.