Partially mocked classes that use a constructor are affected when constructor calls a non-mocked method. In this case the call is intercepted by EasyMock and forwarded to the proxy, while it should have gone to the base method.
It happens because at the time constructor is called in ClassProxyFactory.createProxy() the MockMethodInterceptor instance doesn't have mockedMethods set. To fix this I'd suggest to use the same hack as used for ConstructorArgs - adding a ThreadLocal variable to ClassExtensionHelper.
Please see attached the proposed fix.
Please note: the same bug migrated to EasyMock 3.0 codebase
Log in to post a comment.