mockito-scala icon indicating copy to clipboard operation
mockito-scala copied to clipboard

InvalidUseOfMatchersException on java 19 in presence of default arguments

Open Krever opened this issue 2 years ago • 0 comments

After upgrading to java 19 we started seeing InvalidUseOfMatchersException errors coming from mockito.

trait Foo {
  def bar(a: String, b: Int = 1): Int
}

object Test extends org.mockito.IdiomaticMockito {
  def main(args: Array[String]): Unit = {
    val x = mock[Foo]
    x.bar("a").returns(2)
  }
}

Above code works fine on java 17 but throws on java 19.

Krever avatar Feb 03 '23 11:02 Krever