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
2727
2828import org.mockito.BDDMockito
2929import org.mockito.BDDMockito.BDDMyOngoingStubbing
30+ import org.mockito.stubbing.Answer
3031
3132/* *
3233 * Alias for [BDDMockito.given].
@@ -49,6 +50,13 @@ fun <T> then(mock: T): BDDMockito.Then<T> {
4950 return BDDMockito .then(mock)
5051}
5152
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+
5260/* *
5361 * Alias for [BBDMyOngoingStubbing.willAnswer], accepting a lambda.
5462 */
Original file line number Diff line number Diff line change @@ -3,9 +3,22 @@ package test
33import com.nhaarman.expect.expect
44import com.nhaarman.mockitokotlin2.*
55import org.junit.Test
6+ import org.mockito.stubbing.Answer
67
78class BDDMockitoTest {
89
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+
922 @Test
1023 fun given_willReturn_properlyStubs () {
1124 /* Given */
You can’t perform that action at this time.
0 commit comments