File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2
tests/src/test/kotlin/test Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,15 @@ matrix:
11
11
- jdk : oraclejdk8
12
12
env : TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.2.50
13
13
- jdk : oraclejdk8
14
- env : TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.3.0
14
+ env : TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.3.40
15
15
- jdk : oraclejdk8
16
16
env : TERM=dumb KOTLIN_VERSION=1.0.7
17
17
- jdk : oraclejdk8
18
18
env : TERM=dumb KOTLIN_VERSION=1.1.61
19
19
- jdk : oraclejdk8
20
20
env : TERM=dumb KOTLIN_VERSION=1.2.50
21
21
- jdk : oraclejdk8
22
- env : TERM=dumb KOTLIN_VERSION=1.3.0
22
+ env : TERM=dumb KOTLIN_VERSION=1.3.40
23
23
24
24
25
25
env :
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.invocation.InvocationOnMock
30
31
import org.mockito.stubbing.Answer
31
32
32
33
/* *
@@ -60,8 +61,8 @@ infix fun <T> BDDMyOngoingStubbing<T>.will(value: Answer<T>): BDDMockito.BDDMyOn
60
61
/* *
61
62
* Alias for [BBDMyOngoingStubbing.willAnswer], accepting a lambda.
62
63
*/
63
- infix fun <T > BDDMyOngoingStubbing<T>.willAnswer (value : () -> T ): BDDMockito .BDDMyOngoingStubbing <T > {
64
- return willAnswer { value() }
64
+ infix fun <T > BDDMyOngoingStubbing<T>.willAnswer (value : (InvocationOnMock ) -> T ? ): BDDMockito .BDDMyOngoingStubbing <T > {
65
+ return willAnswer { value(it ) }
65
66
}
66
67
67
68
/* *
Original file line number Diff line number Diff line change @@ -91,6 +91,21 @@ class BDDMockitoTest {
91
91
expect(mock.stringResult()).toBe(" Test" )
92
92
}
93
93
94
+ @Test
95
+ fun given_willAnswerInfix_withInvocationInfo_properlyStubs () {
96
+ /* Given */
97
+ val mock = mock<Methods >()
98
+
99
+ /* When */
100
+ given(mock.stringResult(any())) willAnswer { invocation ->
101
+ (invocation.arguments[0 ] as String )
102
+ .reversed()
103
+ }
104
+
105
+ /* Then */
106
+ expect(mock.stringResult(" Test" )).toBe(" tseT" )
107
+ }
108
+
94
109
@Test(expected = IllegalStateException ::class )
95
110
fun given_willThrowInfix_properlyStubs () {
96
111
/* Given */
You can’t perform that action at this time.
0 commit comments