I understand how to specify extraInterface using the @Mock
annotation, but how can I create a mock and add the extraInterfaces
inline?
@SmallTest
@RunWith(MockitoJUnitRunner::class)
class MyTestClass {
@Mock(extraInterfaces = [MyCallback::class])
lateinit var callbackFragment: Fragment
...
}
But how can I do this on the fly?
// this doesn't compile
val callbackFragment = mock<Fragment>(extraInterfaces = [MyCallback::class])
What is the correct syntax for adding extraInterfaces
to a Mockito mock in Kotlin?
This should work:
val mock = mock<Fragment>(extraInterfaces = arrayOf(MyCallback::class))