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
37
37
*
38
38
* Alias for [Mockito.when].
39
39
*/
40
- fun <T > whenever (methodCall : T ): OngoingStubbing <T > {
40
+ @Suppress(" NOTHING_TO_INLINE" )
41
+ inline fun <T > whenever (methodCall : T ): OngoingStubbing <T > {
41
42
return Mockito .`when `(methodCall)!!
42
43
}
43
44
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import com.nhaarman.mockitokotlin2.*
7
7
import org.junit.Assume.assumeFalse
8
8
import org.junit.Test
9
9
import org.mockito.Mockito
10
+ import org.mockito.exceptions.misusing.UnfinishedStubbingException
10
11
import org.mockito.stubbing.Answer
11
12
12
13
class OngoingStubbingTest : TestBase () {
@@ -319,4 +320,20 @@ class OngoingStubbingTest : TestBase() {
319
320
/* Then */
320
321
expect(mock.stringResult()).toBe(" result" )
321
322
}
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