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 {
6262
6363fun doCallRealMethod (): Stubber = Mockito .doCallRealMethod()!!
6464fun 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)!!
6767fun doThrow (toBeThrown : KClass <out Throwable >): Stubber = Mockito .doThrow(toBeThrown.java)!!
6868fun doThrow (vararg toBeThrown : Throwable ): Stubber = Mockito .doThrow(* toBeThrown)!!
6969
Original file line number Diff line number Diff line change @@ -230,6 +230,25 @@ class MockitoTest {
230230 expect(mock.stringResult()).toBe(" test" )
231231 }
232232
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+
233252 @Test
234253 fun testDoReturnValues () {
235254 val mock = mock<Methods >()
You can’t perform that action at this time.
0 commit comments