Skip to content
Niek Haarman edited this page Aug 19, 2016 · 16 revisions

General FAQs


General

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.

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 ‘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. In its current state, while pretty stable, Mockito-Kotlin is still in an experimental state. Mockito’s 2.x release is nearing, so a choice has been made to write this library around the 2.x-beta versions.

Q: When will this library reach 1.0.0?

A: The Null-safety feature will have to prove its functionality first to ensure a stable 1.x version can be released. Furthermore, Mockito will have to reach 2.x first.

Clone this wiki locally