Closed xpathexception closed 1 year ago
Tested with:
mockmp 1.6.0, 1.8.1 kotlin 1.6.20, 1.7.10
For interfaces, where suspending functions have default implementations, @Mock generates invalid mock implementation.
@Mock
interface Sample { suspend fun sampleSuspending(): String = throw NotImplementedError() }
Generated code (formatted for readability):
import org.kodein.mock.Mocker internal class MockSample( private val mocker: Mocker, ) : Sample { public override suspend fun sampleSuspending(): String { return this.mocker.registerSuspend( receiver = this, method = "sampleSuspending()", default = { super.sampleSuspending() } // <=== Suspension functions can be called only within coroutine body ) } public override fun toString(): String { return this.mocker.register( receiver = this, method = "toString()", default = { super.toString() } ) } }
Version 1.9.0 published with the fix.
1.9.0
Tested with:
mockmp 1.6.0, 1.8.1 kotlin 1.6.20, 1.7.10
For interfaces, where suspending functions have default implementations,
@Mock
generates invalid mock implementation.Generated code (formatted for readability):