dhamini-poornachandra / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

MethodNotFoundException occurs when mocking multiple interfaces #476

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The test case below can pass with mockito 1.8.5 but failed with mockito 1.9.5. 
MethodNotFoundException occurs.

    @Test
    public void test_mock_object_with_multiple_interfaces() throws Exception {
        Runnable runnable = Mockito.mock(Runnable.class, Mockito.withSettings().extraInterfaces(Iterator.class));
        @SuppressWarnings("unchecked")
        Iterator<Object> iterator = (Iterator<Object>) runnable;
        Mockito.when(iterator.next()).thenReturn("test1", "test2");
        Mockito.doThrow(new IllegalStateException()).when(runnable).run();

        Assert.assertEquals("test1", iterator.next());
        Assert.assertEquals("test2", iterator.next());
        try {
            runnable.run();
            Assert.fail("Exception expected.");
        } catch (IllegalStateException e) {
        }
    }

Original issue reported on code.google.com by gavinyan...@gmail.com on 21 Mar 2014 at 2:09

GoogleCodeExporter commented 8 years ago
Could you provide some more details like jdk, platform, OS etc or check it one 
more time. I tested this piece of code on master version as well as on 1.9.5 
and it works correctly: I did not get any exception that was not caught. Maybe 
you forgot to attach something?

Original comment by albers...@gmail.com on 31 Mar 2014 at 8:06