Curious case of MissingMethodInvocationException and Mockito.when
Have you tried to mock a method in Kotlin? As mentioned in this guide we can simply use following code to make it work. //You can mock concrete classes, not just interfaces LinkedList mockedList = mock(LinkedList.class); / /stubbing Mockito.when(mockedList.get(0)).thenReturn("first"); If you try it on kotlin class, it will fail with exception MissingMethodInvocationException. e.g. open class DummyPresenter { fun getSomeValue():String{ return "Some Value" } } @RunWith (MockitoJUnitRunner:: class ) class ExampleUnitTest { @Test fun testCallGetSomeValue() { val presenter: DummyPresenter = mock(DummyPresenter:: class . java ) `when`(presenter.getSomeValue()).thenReturn( "Some other value" ) val result = TestClass().callGetSomeValue(presenter) println ( "Test Result: $ result " ) assertEquals( "Some other value" ,result) } } org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requi...