File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2
tests/src/test/kotlin/test Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package com.nhaarman.mockitokotlin2
27
27
28
28
import org.mockito.BDDMockito
29
29
import org.mockito.BDDMockito.BDDMyOngoingStubbing
30
+ import org.mockito.stubbing.Answer
30
31
31
32
/* *
32
33
* Alias for [BDDMockito.given].
@@ -49,6 +50,13 @@ fun <T> then(mock: T): BDDMockito.Then<T> {
49
50
return BDDMockito .then(mock)
50
51
}
51
52
53
+ /* *
54
+ * Alias for [BDDMyOngoingStubbing.will]
55
+ * */
56
+ infix fun <T > BDDMyOngoingStubbing<T>.will (value : Answer <T >): BDDMockito .BDDMyOngoingStubbing <T > {
57
+ return will(value)
58
+ }
59
+
52
60
/* *
53
61
* Alias for [BBDMyOngoingStubbing.willAnswer], accepting a lambda.
54
62
*/
Original file line number Diff line number Diff line change @@ -3,9 +3,22 @@ package test
3
3
import com.nhaarman.expect.expect
4
4
import com.nhaarman.mockitokotlin2.*
5
5
import org.junit.Test
6
+ import org.mockito.stubbing.Answer
6
7
7
8
class BDDMockitoTest {
8
9
10
+ @Test
11
+ fun given_will_properlyStubs () {
12
+ /* Given */
13
+ val mock = mock<Methods >()
14
+
15
+ /* When */
16
+ given(mock.stringResult()) will Answer <String > { " Test" }
17
+
18
+ /* Then */
19
+ expect(mock.stringResult()).toBe(" Test" )
20
+ }
21
+
9
22
@Test
10
23
fun given_willReturn_properlyStubs () {
11
24
/* Given */
You can’t perform that action at this time.
0 commit comments