provide stub chain methods.
provide stub chain methods.
This class is an implementation of the Answer interface allowing to pass functions as an answer.
support class to create a mock object with a name
This class provide stub methods like returns, throws and answers.
an object allowing the chaining of returned values on doNothing calls.
allows to use a hamcrest matchers to match parameters.
an object allowing the chaining of stub values.
allows to use a specs matcher to match parameters by encapsulating it as a Hamcrest matcher.
allows to use a specs matcher to match parameters by encapsulating it as a Hamcrest matcher.
delegate to MockitoMocker doAnswer with a MockAnswer object using the function f.
create a mock object: val m = mock[java.
create a mock object: val m = mock[java.util.List[String]]
create a mock object with a name: val m = mockAs[java.
create a mock object with a name: val m = mockAs[java.util.List[String]]("name")
implicit allowing the following syntax for a named mock: val m = mock[java.
implicit allowing the following syntax for a named mock: val m = mock[java.util.List[String]],as("name")
create a mock object with smart return values: val m = smartMock[java.
create a mock object with smart return values: val m = smartMock[java.util.List[String]]
This is the equivalent of Mockito.mock(List.class, SMART_NULLVALUES) but testing shows that it is not working well with Scala.
create a spy on an object.
create a spy on an object.
A spy is a real object but can still have some of its methods stubbed. However the syntax for stubbing a spy is a bit different than
with a mock:
val s = spy(new LinkedList[String])
doReturn("one").when(s).get(0) // instead of s.get(0) returns "one" which would throw an exception
an object supporting the stub methods.
This trait provides functionalities to declare stub values on method calls.
Usage:
mockedList.get(0) returns "one" mockedList.get(0) returns ("one", "two") mockedList.get(0) throws new Exception("unexpected") mockedList.get(0) answers ( i => "value " + i.toString )It is also possible to chain stubs like this:
mockedList.get(0) returns "one" thenReturns "two" mockedList.get(0) returns "one" thenThrows new Exception("unexpected now")