Mock return on a static extension method in Kotlin
How do I force a mocked return on a static extension method in Kotlin?
I have a data class called Job
data class Job(
val id: ObjectId) {
}
and a Mapper object with an extension method that's static for the Job class.
object Mapper {
Job.toOtherJob(): OtherJob.Job {
// Do work
}
}
The issue is that toOtherJob method calls the real one, and I cannot force a doReturn on it.
Test class
class ServiceTests {
@Mock
private val job: Job? = null
@BeforeAll
fun...