File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
mockito-kotlin/src/main/kotlin/org/mockito/kotlin
tests/src/test/kotlin/test Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,11 @@ package org.mockito.kotlin
2828import org.mockito.stubbing.LenientStubber
2929import org.mockito.stubbing.OngoingStubbing
3030
31- inline fun <reified T : Any > LenientStubber.whenever (methodCall : T ): OngoingStubbing <T > {
31+ inline fun <reified T > LenientStubber.whenever (methodCall : T ): OngoingStubbing <T > {
3232 return `when `(methodCall)
3333}
3434
35- inline fun <reified T : Any > LenientStubber.whenever (methodCall : () -> T ): OngoingStubbing <T > {
35+ inline fun <reified T > LenientStubber.whenever (methodCall : () -> T ): OngoingStubbing <T > {
3636 return whenever(methodCall())
3737}
3838
Original file line number Diff line number Diff line change @@ -34,4 +34,18 @@ open class LenientStubberTest {
3434
3535 Assert .assertEquals(" List should contain hello" , " hello" , mock[1 ])
3636 }
37+
38+ @Test
39+ fun unused_and_lenient_stubbings_with_nullable () {
40+ val mock = mock<NullableToString >()
41+ lenient().whenever(mock.returnsNullableString()).doReturn(null )
42+ whenever(mock.returnsNonNullableString()).doReturn(" hello" )
43+
44+ Assert .assertEquals(" Should return hello" , " hello" , mock.returnsNonNullableString())
45+ }
46+
47+ private class NullableToString {
48+ fun returnsNullableString (): String? = " "
49+ fun returnsNonNullableString (): String = " "
50+ }
3751}
You can’t perform that action at this time.
0 commit comments