mockito-kotlin
mockito-kotlin copied to clipboard
Using Mockito with Kotlin
I just cloned the repo and runed `./gradlew test` and the project failed with lots of errors ```shell w: /Users/brais/projects/mockito-kotlin/mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2/internal/CreateInstance.kt: (45, 30): Parameter 'kClass' is never used e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (5,...
Hi, I have function which has 3 parameters and 2 of these parameters are functions. However when i try to verify a function i get this error. ``` Argument(s) are...
@nhaarman , the area that I was trying to test was like this ``` val testArg = mock Unit>() val result = someClass.doSomething(testArg) verify(testArg).invoke(any()) ``` And the error comes out...
Very common case when writing Mockito doAnswer is to return a value based on the input parameters. I've added the following infix function many times in code (and its multiple...
Assume you have a sealed class hierarchy as follows: ``` sealed class MyType { data class Open(val something: String) : MyType() data class Finish(val reason: String) : MyType() } ```...
Mockito returns null for any invocation where no expectation was set up. If the method return type is non-nullable in Kotlin you get an NPE at a point it shouldn't...
I'm referring to https://youtu.be/MyljSWm0Y_k?t=1282 I turned it on this way ```groovy tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { kotlinOptions { // progressive helps detecting unstable Kotlin code earlier, see https://blog.jetbrains.com/kotlin/2018/06/kotlin-1-2-50-is-out/ freeCompilerArgs = ["-Xjsr305=strict", "-progressive", "-XXLanguage:+NewInference",...
I'm trying to write a unit test using your library version 2.0.0-RC2 and have the following code: ``` @Captor val captor = argumentCaptor() ``` and it gives me a error:...
Verification of method invocations can fail in a non-obvious way if the method takes default arguments, e.g.: val foo = mock() foo.beta(4) verify(foo).beta() Here we're trying to `verify` that `beta()`...
I have the following test: ``` private var interceptSelectedRoute = mock() @Captor val interceptSelectedRouteCaptor = argumentCaptor() ``` ``` @Test fun `when selected route is intercepted, we should start persisting it`()...