I want to mock an Android drawable for some unit tests. I'm using the @Mockk
annotations. This is the code:
@MockK
lateinit var mockIcon: Drawable
@Before
fun setUp() {
MockKAnnotations.init(this)
}
When I run this code, I get this error lateinit property mockIcon has not been initialized
But when I use the mockk()
function instead, the code runs successfully:
val mockIcon: Drawable = mockk()
I don't understand what causes this issue. Is there a difference between the @Mockk
annotation and mockk()
function?
Thanks in advance