File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ import org.mockito.verification.VerificationMode
30
30
import kotlin.reflect.KClass
31
31
32
32
inline fun <reified T : Any > mock () = Mockito .mock(T ::class .java)
33
+ inline fun <reified T : Any > mock (defaultAnswer : Answer <Any >) = Mockito .mock(T ::class .java, defaultAnswer)
33
34
fun <T : Any > spy (value : T ) = Mockito .spy(value)
34
35
35
36
fun <T > whenever (methodCall : T ) = Mockito .`when `(methodCall)
@@ -40,6 +41,17 @@ fun <T> reset(mock: T) = Mockito.reset(mock)
40
41
41
42
fun inOrder (vararg value : Any ) = Mockito .inOrder(* value)
42
43
fun never () = Mockito .never()
44
+ fun times (numInvocations : Int ) = Mockito .times(numInvocations)
45
+ fun atLeast (numInvocations : Int ) = Mockito .atLeast(numInvocations)
46
+ fun atLeastOnce () = Mockito .atLeastOnce()
47
+
48
+ fun doReturn (value : Any ) = Mockito .doReturn(value)
49
+ fun doThrow (throwable : Throwable ) = Mockito .doThrow(throwable)
50
+ fun <T > doAnswer (answer : Answer <T >) = Mockito .doAnswer(answer)
51
+ fun doCallRealMethod () = Mockito .doCallRealMethod()
52
+ fun doNothing () = Mockito .doNothing()
53
+
54
+ fun <T > Stubber.whenever (mock : T ) = `when `(mock)
43
55
44
56
inline fun <reified T : Any > eq (value : T ) = Mockito .eq(value) ? : createInstance<T >()
45
57
inline fun <reified T : Any > anyArray (): Array <T > = Mockito .any(Array <T >::class .java) ? : arrayOf()
You can’t perform that action at this time.
0 commit comments