Testing closed classes

There is one small challenge associated with mocking in Kotlin. As you may remember, classes in Kotlin are closed by default, meaning they cannot be inherited from without explicitly being marked as open. This is incompatible with common mocking frameworks, such as Mockito. However, there are several ways to work around this issue, and we will take a look at both in the following sections.