package info import org.junit.Rule import org.mockito.Mockito import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule open class TestBase { // Add a JUnit rule that will setup the @Mock annotated vars and log. // Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method. @get:Rule val mockitoRule: MockitoRule = MockitoJUnit.rule() // Workaround for Kotlin nullability. // https://medium.com/@elye.project/befriending-kotlin-and-mockito-1c2e7b0ef791 // https://stackoverflow.com/questions/30305217/is-it-possible-to-use-mockito-in-kotlin fun anyObject(): T { Mockito.any() return uninitialized() } @Suppress("Unchecked_Cast") fun uninitialized(): T = null as T }