e: ...kt:0:0 Cannot access class 'org.mockito.stubbing.Stubber'. Check your module classpath for missing or conflicting dependencies
e: ...kt:0:0 Cannot access class 'org.mockito.invocation.InvocationOnMock'. Check your module classpath for missing or conflicting dependencies
e: ...kt:0:0 Unresolved reference: callRealMethod
Repro
interface Factory {
fun create(): String
}
@Test fun test() {
val mock = mock<Factory>()
doAnswer { it.callRealMethod() } // More complex IRL, just simplified, because it doesn't matter.
.whenever(mock)
.create()
}
Note: somehow by simplifying Kotlin knows what InvocationOnMock & callRealMethod is, but it shouldn't, anyway whenever is still broken.
When upgrading Gradle from compile to implementation @Nynuzoud didn't make an equivalent change. It is a compatible change for most normal projects, but this is a published library, so the equivalent new configuration should be api so that Gradle generates compile in the POM.
Note: you don't observe this, because the tests explicitly depend on transitive dependencies, not via POM.
Symptom
Repro
InvocationOnMock
&callRealMethod
is, but it shouldn't, anywaywhenever
is still broken.Issue
Compare: https://repo1.maven.org/maven2/org/mockito/kotlin/mockito-kotlin/5.1.0/mockito-kotlin-5.1.0.pom https://repo1.maven.org/maven2/org/mockito/kotlin/mockito-kotlin/5.2.0/mockito-kotlin-5.2.0.pom
Diff
Background
Root cause is this change: https://github.com/mockito/mockito-kotlin/pull/496/files#diff-09728e1a022bed42cb4f8d1d2418235341d939c7f641a015f30648911ec97cc4R29
When upgrading Gradle from
compile
toimplementation
@Nynuzoud didn't make an equivalent change. It is a compatible change for most normal projects, but this is a published library, so the equivalent new configuration should beapi
so that Gradle generatescompile
in the POM.Note: you don't observe this, because the tests explicitly depend on transitive dependencies, not via POM.
https://github.com/mockito/mockito-kotlin/blob/5.2.0/tests/build.gradle#L31