File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2
tests/src/test/kotlin/test Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ import kotlin.reflect.KClass
3737 *
3838 * Alias for [Mockito.when].
3939 */
40- fun <T > whenever (methodCall : T ): OngoingStubbing <T > {
40+ @Suppress(" NOTHING_TO_INLINE" )
41+ inline fun <T > whenever (methodCall : T ): OngoingStubbing <T > {
4142 return Mockito .`when `(methodCall)!!
4243}
4344
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import com.nhaarman.mockitokotlin2.*
77import org.junit.Assume.assumeFalse
88import org.junit.Test
99import org.mockito.Mockito
10+ import org.mockito.exceptions.misusing.UnfinishedStubbingException
1011import org.mockito.stubbing.Answer
1112
1213class OngoingStubbingTest : TestBase () {
@@ -319,4 +320,20 @@ class OngoingStubbingTest : TestBase() {
319320 /* Then */
320321 expect(mock.stringResult()).toBe(" result" )
321322 }
322- }
323+
324+ @Test
325+ fun testMockitoStackOnUnfinishedStubbing () {
326+ /* Given */
327+ val mock = mock<Open >()
328+ whenever(mock.stringResult())
329+
330+ /* When */
331+ try {
332+ mock.stringResult()
333+ } catch (e: UnfinishedStubbingException ) {
334+ /* Then */
335+ expect(e.message).toContain(" Unfinished stubbing detected here:" )
336+ expect(e.message).toContain(" -> at test.OngoingStubbingTest.testMockitoStackOnUnfinishedStubbing" )
337+ }
338+ }
339+ }
You can’t perform that action at this time.
0 commit comments