-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
My project only had included mockito-scala
as dependency.
When upgrading to JDK21, we've got the following error:
[info] org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: interface zio.ZIO.
[info]
[info] If you're not sure why you're getting this error, please open an issue on GitHub.
[info]
[info]
[info] Java : 21
[info] JVM vendor name : Oracle Corporation
[info] JVM vendor version : 21.0.1+12-jvmci-23.1-b19
[info] JVM name : Java HotSpot(TM) 64-Bit Server VM
[info] JVM version : 21.0.1+12-jvmci-23.1-b19
[info] JVM info : mixed mode, sharing
[info] OS name : Mac OS X
[info] OS version : 13.3.1
[info]
[info]
[info] You are seeing this disclaimer because Mockito is configured to create inlined mocks.
[info] You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.
[info]
[info] Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [interface scala.Product, interface java.io.Serializable, interface zio.ZIOPlatformSpecific, interface zio.ZIOVersionSpecific, interface zio.ZIO, interface scala.Equals]
[info] at scala.Option.orElse(Option.scala:477)
[info] at com.acme.xxx.masterdata.plots.services.getcalculationparameters.impl.GetCalculationParametersServiceSpec.$anonfun$new$2(GetCalculationParametersServiceSpec.scala:98)
[info] at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[info] at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[info] at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[info] at org.scalatest.Transformer.apply(Transformer.scala:22)
[info] at org.scalatest.Transformer.apply(Transformer.scala:20)
[info] at org.scalatest.wordspec.AnyWordSpecLike$$anon$3.apply(AnyWordSpecLike.scala:1240)
[info] at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
[info] at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
our Dependencies.scala looks like this
val mockitoScalaVersion = "1.17.29"
val mockitoCoreVersion = "5.7.0"
object Mockito {
val core = "org.mockito" % "mockito-core" % V.mockitoCoreVersion
val scala = "org.mockito" %% "mockito-scala" % V.mockitoScalaVersion
val scalaScalatest = "org.mockito" %% "mockito-scala-scalatest" % V.mockitoScalaVersion
val scalaCats = "org.mockito" %% "mockito-scala-cats" % V.mockitoScalaVersion
}
Without the explicit inclusion of mockito-core
an old version of mockito was pulled in which included a bytebuddy version that does not yet understand JDK21 classes.
conet and karlroberts
Metadata
Metadata
Assignees
Labels
No labels