Often when writing unit test cases for complex classes, we face the problem of instantiating a great number of properties that the class we want to test depends on. Although this problem could be solved with dependency injection, it is faster, more efficient, and more desirable to mock a behavior of a specific object without instantiating it at all. In this recipe, we are going to explore how to use the Mockito Kotlin library to mock dependencies when writing a unit test for a simple registration form that contains an internal dependency whose behavior we are going to mock.
Mocking dependencies with the Mockito Kotlin library
Getting ready
We are going to use the JUnit library, which provides the core framework for running...