I've been away from mockito for awhile, so this is probably a newbie issue.
package somepackage
import org.junit.jupiter.api.Test
import org.mockito.kotlin.doNothing
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever
var called = false
open class SUT {
fun doWork(type: String) {
println("Doing $type work")
called = true
}
}
class MockTest {
@Test
fun `test doNothing`() {
val sut: SUT = mock()
doNothing().whenever(sut).doWork("busy")
sut.doWork("busy")
assert(!called)
}
}
The test fails as doWork()
was called. Twice. If I replace "busy" with any()
in the mock, it fails with a NPE.
I'm expecting it to not call the actual method and do, well, nothing. Any ideas?