-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hi, I struggle with finding a method for mocking, when the method has default arguments.
The following fails with java.lang.AssertionError: Unexpected method call Foo.bar$default$2()
//> using dep "org.scalatest::scalatest:3.2.17"
//> using dep "org.scalatestplus::easymock-5-1:3.2.17.0"
//> using dep "org.easymock:easymock:5.1.0"
import org.scalatestplus.easymock.EasyMockSugar
import org.scalatest.funsuite.AnyFunSuite
import org.easymock.EasyMock.{capture, newCapture}
trait Foo {
def bar(a: String, b: Int = 0): String
}
class EasyMockTest extends AnyFunSuite with EasyMockSugar {
test("test") {
val foo = mock[Foo]
val aCapture = newCapture[String]
val bCapture = newCapture[Int]
expecting {
foo.bar(capture(aCapture), capture(bCapture)).andStubReturn("bar")
}
whenExecuting(foo) {
val bar1 = foo.bar("a", 0)
assert(bar1 == "bar")
val bar2 = foo.bar("a")
assert(bar2 == "bar")
}
}
}
Metadata
Metadata
Assignees
Labels
No labels