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
27
27
28
28
import org.mockito.Answers
29
29
import org.mockito.internal.creation.MockSettingsImpl
30
+ import org.mockito.internal.creation.bytebuddy.MockMethodInterceptor
30
31
import org.mockito.internal.util.MockUtil
31
32
import java.lang.reflect.Modifier
32
33
import java.lang.reflect.ParameterizedType
@@ -160,5 +161,7 @@ private fun <T : Any> KType.createNullableInstance(): T? {
160
161
private fun <T > Class<T>.uncheckedMock (): T {
161
162
val impl = MockSettingsImpl <T >().defaultAnswer(Answers .RETURNS_DEFAULTS ) as MockSettingsImpl <T >
162
163
val creationSettings = impl.confirm(this )
163
- return MockUtil ().createMock(creationSettings)
164
+ return MockUtil ().createMock(creationSettings).apply {
165
+ (this as MockMethodInterceptor .MockAccess ).mockitoInterceptor = null
166
+ }
164
167
}
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ interface Methods {
49
49
fun closedSet (s : Set <Closed >)
50
50
fun string (s : String )
51
51
fun closedVararg (vararg c : Closed )
52
+ fun throwableClass (t : ThrowableClass )
52
53
53
54
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
3
3
import com.nhaarman.mockito_kotlin.*
4
4
import org.junit.Test
5
5
import org.mockito.exceptions.base.MockitoAssertionError
6
+ import java.io.IOException
6
7
7
8
/*
8
9
* The MIT License
@@ -107,6 +108,14 @@ class MockitoTest {
107
108
}
108
109
}
109
110
111
+ @Test
112
+ fun anyThrowableWithSingleThrowableConstructor () {
113
+ mock<Methods >().apply {
114
+ throwableClass(ThrowableClass (IOException ()))
115
+ verify(this ).throwableClass(any())
116
+ }
117
+ }
118
+
110
119
@Test
111
120
fun listArgThat () {
112
121
mock<Methods >().apply {
You can’t perform that action at this time.
0 commit comments