Hi, I’m having an issue with Mockito and Kotlin. W...
# announcements
a
Hi, I’m having an issue with Mockito and Kotlin. When I mock a function response, it’s calling the real function, which make the test fail. An example of this:
Copy code
class MockitoTest {

    open class FailExample(val property: String) {
        fun execute() = property.toString()
    }

    @Test fun mockitoCanMock() {
        val myMock = Mockito.mock(FailExample::class.java)
        Mockito.`when`(myMock.execute()).thenReturn("Hello")
        assertEquals("Hello", myMock.execute())
    }
}