https://kotlinlang.org logo
#android
Title
# android
d

Daniel

02/12/2018, 9:53 PM
A rather serious question regarding android instrumentation testing and kotlin: Is there a way in sight to mock kotlin classes in android ui tests? Using Dexopener and the AllOpen plugin feels.. kind of hacky and not very 'native'.
d

dgngulcan

02/12/2018, 10:52 PM
I am using Mockito to mock my both kotlin and java classes and it is working flawlessly.
d

Daniel

02/12/2018, 11:11 PM
In Instrumented tests? In Unit Test it works indeed fine with mock-maker-inline
d

dgngulcan

02/13/2018, 7:12 PM
Yes, it just works in instrumentation tests as below.
testCompile group: 'org.mockito', name: 'mockito-inline', version: '2.13.0'
Copy code
@Mock private lateinit var onMarkerClickListener: OnMarkerClickListener`

    @Before
    @UiThreadTest
    fun init() {
        MockitoAnnotations.initMocks(this)
    ...
    }
3 Views