File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
main/kotlin/com/nhaarman/mockito_kotlin Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ class MockitoKotlin {
78
78
?.second
79
79
}
80
80
81
- private fun StackTraceElement.toFileIdentifier () = " $fileName$className "
81
+ private fun StackTraceElement.toFileIdentifier () = " $fileName$className " .let {
82
+ if (it.contains(" $" )) it.substring(0 .. it.indexOf(" $" ) - 1 ) else it
83
+ }
82
84
}
83
85
}
Original file line number Diff line number Diff line change 24
24
*/
25
25
26
26
import com.nhaarman.expect.expect
27
- import com.nhaarman.mockito_kotlin.MockitoKotlin
28
- import com.nhaarman.mockito_kotlin.createInstance
27
+ import com.nhaarman.mockito_kotlin.*
28
+ import org.junit.After
29
29
import org.junit.Test
30
30
31
31
class MockitoKotlinTest {
32
32
33
+ @After
34
+ fun teardown () {
35
+ MockitoKotlin .resetInstanceCreators()
36
+ }
37
+
33
38
@Test
34
39
fun register () {
35
40
/* Given */
@@ -56,4 +61,18 @@ class MockitoKotlinTest {
56
61
/* Then */
57
62
expect(result).toNotBeTheSameAs(closed)
58
63
}
64
+
65
+ @Test
66
+ fun usingInstanceCreatorInsideLambda () {
67
+ MockitoKotlin .registerInstanceCreator { CreateInstanceTest .ForbiddenConstructor (2 ) }
68
+
69
+ mock<TestClass > {
70
+ on { doSomething(any()) } doReturn " "
71
+ }
72
+ }
73
+
74
+ interface TestClass {
75
+
76
+ fun doSomething (c : CreateInstanceTest .ForbiddenConstructor ): String
77
+ }
59
78
}
You can’t perform that action at this time.
0 commit comments