Given the following code that mocks a Scala class with Mockito, I get an error and cannot compile:
import org.mockito.Mockito._
class Testeable {
def fun1 = 1
def fun2 = 2
}
object test {
def getMock = {
val testMock = mock[Testeable] // <-- this line throws the error
when(testMock.fun1).thenReturn(3)
testMock
}
}
Error is:
ambiguous reference to overloaded definition, both method mock in object Mockito of type (x$1: Class[common.Testeable], x$2: org.mockito.MockSettings)common.Testeable and method mock in object Mockito of type (x$1: Class[common.Testeable], x$2: org.mockito.stubbing.Answer[_])common.Testeable match expected type ?
I just mocked a class, what's ambiguous?