Failing the clone() method on the interface no longer works with Mockito 2.1.0 . Below code works fine with Mockito 1.10.19 , but throws IllegalAccessError with Mockito 2.1.0 :
public interface CloneableInterface extends Cloneable { CloneableInterface clone(); } public class CloneableInterfaceTest { @Test public void test() { CloneableInterface i = Mockito.mock(CloneableInterface.class); Mockito.when(i.clone()).thenReturn(i);
Test result:
java.lang.IllegalAccessError: CloneableInterface$MockitoMock$833899610.clone()LCloneableInterface;
I checked the mockito error list and searched a bit, but found nothing. I wanted to check the SO community before reporting a bug with the mockito team.
Environment: JDK 1.8.0_102 , JUnit 4.11 , Mockito 2.1.0 , Gradle 3.0 , Windows 10
EDIT: Failed mockito command here
source share