File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -62,8 +62,8 @@ fun <T> doAnswer(answer: (InvocationOnMock) -> T?): Stubber = Mockito.doAnswer {
62
62
63
63
fun doCallRealMethod (): Stubber = Mockito .doCallRealMethod()!!
64
64
fun doNothing (): Stubber = Mockito .doNothing()!!
65
- fun doReturn (value : Any ): Stubber = Mockito .doReturn(value)!!
66
- fun doReturn (toBeReturned : Any , vararg toBeReturnedNext : Any ): Stubber = Mockito .doReturn(toBeReturned, * toBeReturnedNext)!!
65
+ fun doReturn (value : Any? ): Stubber = Mockito .doReturn(value)!!
66
+ fun doReturn (toBeReturned : Any? , vararg toBeReturnedNext : Any? ): Stubber = Mockito .doReturn(toBeReturned, * toBeReturnedNext)!!
67
67
fun doThrow (toBeThrown : KClass <out Throwable >): Stubber = Mockito .doThrow(toBeThrown.java)!!
68
68
fun doThrow (vararg toBeThrown : Throwable ): Stubber = Mockito .doThrow(* toBeThrown)!!
69
69
Original file line number Diff line number Diff line change @@ -230,6 +230,25 @@ class MockitoTest {
230
230
expect(mock.stringResult()).toBe(" test" )
231
231
}
232
232
233
+ @Test
234
+ fun testDoReturnNullValue () {
235
+ val mock = mock<Methods >()
236
+
237
+ doReturn(null ).whenever(mock).stringResult()
238
+
239
+ expect(mock.stringResult()).toBeNull()
240
+ }
241
+
242
+ @Test
243
+ fun testDoReturnNullValues () {
244
+ val mock = mock<Methods >()
245
+
246
+ doReturn(null , null ).whenever(mock).stringResult()
247
+
248
+ expect(mock.stringResult()).toBeNull()
249
+ expect(mock.stringResult()).toBeNull()
250
+ }
251
+
233
252
@Test
234
253
fun testDoReturnValues () {
235
254
val mock = mock<Methods >()
You can’t perform that action at this time.
0 commit comments