org.specs2.mock.mockito

MockitoStubs

trait MockitoStubs extends MocksCreation

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")

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. MockitoStubs
  2. MocksCreation
  3. TheMockitoMocker
  4. AnyRef
  5. Any
Visibility
  1. Public
  2. All

Type Members

  1. class AStubber [T] extends AnyRef

    provide stub chain methods.

  2. class AnOngoingStubbing [T] extends AnyRef

    provide stub chain methods.

  3. class MockAnswer [T] extends Answer[T]

    This class is an implementation of the Answer interface allowing to pass functions as an answer.

  4. class NamedMock [T] extends AnyRef

    support class to create a mock object with a name

  5. class Stubbed [T] extends AnyRef

    This class provide stub methods like returns, throws and answers.

Value Members

  1. def != (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  2. def != (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  3. def ## (): Int

    Attributes
    final
    Definition Classes
    AnyRef → Any
  4. def == (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  5. def == (arg0: Any): Boolean

    Attributes
    final
    Definition Classes
    Any
  6. implicit def aStubber (stub: ⇒ Stubber): AStubber[Nothing]

    returns

    an object allowing the chaining of returned values on doNothing calls.

    Attributes
    implicit
  7. def anArgThat [T, U <: T] (m: Matcher[U]): T

    allows to use a hamcrest matchers to match parameters.

  8. implicit def anOngoingStubbing [T] (stub: ⇒ OngoingStubbing[T]): AnOngoingStubbing[T]

    returns

    an object allowing the chaining of stub values.

    Attributes
    implicit
  9. implicit def argThat [T, U <: T] (m: Matcher[U]): T

    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.

    Attributes
    implicit
  10. def asInstanceOf [T0] : T0

    Attributes
    final
    Definition Classes
    Any
  11. def clone (): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  12. def doAnswer [T] (f: (Any) ⇒ T): Stubber

    delegate to MockitoMocker doAnswer with a MockAnswer object using the function f.

  13. def eq (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  14. def equals (arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  15. def finalize (): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  16. def getClass (): java.lang.Class[_]

    Attributes
    final
    Definition Classes
    AnyRef → Any
  17. def hashCode (): Int

    Definition Classes
    AnyRef → Any
  18. def isInstanceOf [T0] : Boolean

    Attributes
    final
    Definition Classes
    Any
  19. def mock [T] (implicit arg0: ClassManifest[T]): T

    create a mock object: val m = mock[java.

    create a mock object: val m = mock[java.util.List[String]]

    Definition Classes
    MocksCreation
  20. def mockAs [T] (name: String)(implicit arg0: ClassManifest[T]): T

    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")

    Definition Classes
    MocksCreation
  21. implicit def mockToAs [T] (t: ⇒ T)(implicit arg0: ClassManifest[T]): NamedMock[T]

    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")

    Attributes
    implicit
    Definition Classes
    MocksCreation
  22. def ne (arg0: AnyRef): Boolean

    Attributes
    final
    Definition Classes
    AnyRef
  23. def notify (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  24. def notifyAll (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
  25. def smartMock [T] (implicit arg0: ClassManifest[T]): T

    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.

    Definition Classes
    MocksCreation
  26. def spy [T] (m: T): T

    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

    Definition Classes
    MocksCreation
  27. def synchronized [T0] (arg0: ⇒ T0): T0

    Attributes
    final
    Definition Classes
    AnyRef
  28. implicit def theStubbed [T] (c: ⇒ T): Stubbed[T]

    returns

    an object supporting the stub methods.

    Attributes
    implicit
  29. def toString (): String

    Definition Classes
    AnyRef → Any
  30. def wait (): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  31. def wait (arg0: Long, arg1: Int): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()
  32. def wait (arg0: Long): Unit

    Attributes
    final
    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from MocksCreation

Inherited from TheMockitoMocker

Inherited from AnyRef

Inherited from Any