File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ package com.nhaarman.mockito_kotlin
2727
2828import org.mockito.Answers
2929import org.mockito.internal.creation.MockSettingsImpl
30+ import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor
3031import org.mockito.internal.util.MockUtil
3132import java.lang.reflect.Modifier
3233import java.lang.reflect.ParameterizedType
@@ -160,5 +161,7 @@ private fun <T : Any> KType.createNullableInstance(): T? {
160161private fun <T > Class<T>.uncheckedMock (): T {
161162 val impl = MockSettingsImpl <T >().defaultAnswer(Answers .RETURNS_DEFAULTS ) as MockSettingsImpl <T >
162163 val creationSettings = impl.confirm(this )
163- return MockUtil ().createMock(creationSettings)
164+ return MockUtil ().createMock(creationSettings).apply {
165+ (this as MockMethodInterceptor .MockAccess ).mockitoInterceptor = null
166+ }
164167}
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ interface Methods {
4949 fun closedSet (s : Set <Closed >)
5050 fun string (s : String )
5151 fun closedVararg (vararg c : Closed )
52+ fun throwableClass (t : ThrowableClass )
5253
5354 fun stringResult (): String
54- }
55+ }
56+
57+ class ThrowableClass (cause : Throwable ) : Throwable(cause)
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import com.nhaarman.expect.expectErrorWithMessage
33import com.nhaarman.mockito_kotlin.*
44import org.junit.Test
55import org.mockito.exceptions.base.MockitoAssertionError
6+ import java.io.IOException
67
78/*
89 * The MIT License
@@ -107,6 +108,14 @@ class MockitoTest {
107108 }
108109 }
109110
111+ @Test
112+ fun anyThrowableWithSingleThrowableConstructor () {
113+ mock<Methods >().apply {
114+ throwableClass(ThrowableClass (IOException ()))
115+ verify(this ).throwableClass(any())
116+ }
117+ }
118+
110119 @Test
111120 fun listArgThat () {
112121 mock<Methods >().apply {
You can’t perform that action at this time.
0 commit comments