https://kotlinlang.org logo
#mockk
Title
# mockk
g

groostav

01/31/2019, 11:01 PM
hey so, I started using mockk and I got some really strange behaviour that simply comes from mockito-like stack-index-checking. Can I ask you guys why you went with mockito style DSL when kotlin has such nice method references? Using kotlin method references, you can ditch all of the scary not-thread-safe parameter/argument capturing in mockito and provide a pretty slick DSL:
Copy code
fun usage(){
    val result2 = buildMock<java.lang.ProcessBuilder>{
        ProcessBuilder::inheritIO {
            TODO()
        }

        //one problem with method refs is that they are ambiguous when the method is overloaded
        // but inference takes care of that reasonably elegently
        oneArg(ProcessBuilder::directory).invokes {
            TODO()
        }
    }
I also think that using kotlin property references could make mocking of properties much nicer
o

oleksiyp

02/02/2019, 8:56 PM
I am not sure about what stack-index-checking you are talking about. MockK main innovation(and it's superiority to Mockito) is that it allows any argument matchers in any position and doesn't rely on counting. What nice this is achievable only in Kotlin. It is alike killer feature 😄 if this is changed it will be totally different library. So please be more specific what issues you faced(better github issues request) and explain your approach better.
7 Views