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 {
7878 ?.second
7979 }
8080
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+ }
8284 }
8385}
Original file line number Diff line number Diff line change 2424 */
2525
2626import 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
2929import org.junit.Test
3030
3131class MockitoKotlinTest {
3232
33+ @After
34+ fun teardown () {
35+ MockitoKotlin .resetInstanceCreators()
36+ }
37+
3338 @Test
3439 fun register () {
3540 /* Given */
@@ -56,4 +61,18 @@ class MockitoKotlinTest {
5661 /* Then */
5762 expect(result).toNotBeTheSameAs(closed)
5863 }
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+ }
5978}
You can’t perform that action at this time.
0 commit comments