TacapeForte / android-mock

Automatically exported from code.google.com/p/android-mock
0 stars 0 forks source link

Package-private methods cannot be mocked #14

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Create a class containing a non-final, package-private instance method (i.e. no 
modifiers at all) and attempt to create a mock for the class in a unit test 
using android-mock. 

Given that EasyMock supports mocking package-private methods, we should be able 
to define mock behaviour for the method - expectations, return values etc. and 
be able to verify this behaviour as with methods explicitly declared protected 
or public. 

However, what actually happens is the package-private method is not mocked and 
the actual implementation gets called when setting up an expectation for it. 

This affects the head of the trunk. 

I have tweaked AndroidMockGenerator.isMockable() in my local working copy to 
allow anything not marked private to be mocked, allowing public, protected and 
package-private methods to be mocked. I have tested this change successfully 
and attached a patch. 

Original issue reported on code.google.com by t...@leach.it on 14 Jul 2011 at 10:46

Attachments: