Inherited from ArgumentMatchersSugar
Inherited from MacroBasedMatchers
Inherited from NumericMatchers
Inherited from Tolerance
Inherited from FunctionMatchers
Inherited from NullMatchers
Inherited from StringThatMatchers
Inherited from ThatMatchers
Inherited from EqMatchers_VersionSpecific
Inherited from EqMatchers
Inherited from AnyMatchers
Inherited from IdiomaticMockito
Inherited from PostfixVerifications
Inherited from IdiomaticVerifications
Inherited from IdiomaticStubbing
Inherited from ScalacticSerialisableHack
Inherited from MockitoEnhancer
Inherited from MockCreator
Inherited from AnyRef
Inherited from Any
Helper for Mockito Scala sugar with idiomatic stubbing. Java users are encouraged to use
org.mockito.Mockito
directly.Note that the Specs2
smartMock[]
ormock[].smart
is the default behavior for Mockito Scala.Usage
This trait uses
org.mockito.IdiomaticMockito
which is heavily influenced by ScalaTest Matchers.To use, mix in the com.twitter.util.mock.Mockito trait where desired.
Create a new mock
Expect behavior
Note the 'dead code' warning that can happen when using 'any' or '*' matchers.
Mixing and matching matchers
Using the idiomatic syntax also allows for mixing argument matchers with real values. E.g., you are no longer forced to use argument matchers for all parameters as soon as you use one. E.g.,
See Mix-and-Match for more information including a caveat around curried functions with default arguments.
Numeric Matchers
Numeric comparisons are possible for argument matching, e.g.,
See Numeric Matchers.
Vargargs
Most matches will deal with varargs out of the box, just note when using the 'eqTo' matcher to apply it to all the arguments as one (not individually).
See Varargs.
More Information
See the IdiomaticMockito documentation for more specific information and the Mockito Scala Getting Started documentation for general information.
see
org.mockito.IdiomaticMockito
seeorg.mockito.ArgumentMatchersSugar