-
Notifications
You must be signed in to change notification settings - Fork 202
- Will this library help mocking closed (non-open) classes?
- Will this library help overcoming NullPointerExceptions?
- I get an error ‘Resolved versions for app (1.1.x) and test app (1.0.x) differ’. What should I do?
- I get an error ‘Could not create an instance of class’. What should I do?
- Will this library support Mockito 1.x?
Q: Will this library help mocking closed (non-open) classes?
A: Mockito-Kotlin does not really add any extra functionality to Mockito. As such, you will still get exceptions when trying to mock closed classes. If possible, try to use interfaces instead.
Mockito provides an incubating, opt-in feature to enable mocking closed classes. See Mock the unmockable for more details.
Q: Will this library help overcoming NullPointerExceptions with Mockito.any()?
A: Passing Mockito.any() to a non-nullable parameter in Kotlin fails with a NullPointerException. Mockito-Kotlin tries to overcome this. See Null-safety for more info.
Q: I get an error ‘Resolved versions for app (1.1.x) and test app (1.0.x) differ’. What should I do?
A: Mockito-Kotlin depends on version `1.0.x` of Kotlin’s standard and reflect library. If you depend on `1.1.x`, you may get this error. To solve this, add the following snippet to your root’s `build.gradle`:
subprojects {
configurations.all {
resolutionStrategy {
forcedModules = [
"org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
"org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
]
}
}
}
Q: I get an error ‘Could not create an instance of class’. What should I do?
A: Register an instance creator, as described in Null-safety.
Q: Will this library support Mockito 1.x?
A: No. Mockito 2.x is officially released and this library will focus on these versions.
Q: When will this library reach 1.0.0?
A: Mockito-Kotlin reached 1.0.0 December 6th. Try it out!