Open GoogleCodeExporter opened 8 years ago
One workaround for this is for dexmaker to avoid calling super class methods
that are "uncallable".
This will have the (possibly undesirable) effect of uncallable methods not
being called, which could lead to an out-of-state object but this is often
preferable to complete failure.
I have a patched version of dexmaker with this change here:
https://code.google.com/r/jp-dexmaker/
Specifically:
https://code.google.com/r/jp-dexmaker/source/browse/dexmaker/src/main/java/com/g
oogle/dexmaker/stock/ProxyBuilder.java#523
Original comment by j...@sharethis.com
on 11 Dec 2013 at 12:54
Unfortunately package-private only works if you can load the mock class in the
same class loader as the target class. We don't have a hack that'll work on
Dalvik to do this. If you'd like to attempt one, please do!
Original comment by limpbizkit
on 11 Dec 2013 at 1:10
In the cases I've encountered so far this issue presents when trying to spy
Android framework classes (famously when mocking views and their children),
which call internal package-private methods during initialization. Simply
avoiding invocation on these "guaranteed to fail" methods allows for the view
to be mocked, but obviously does have the effect of not "truly" representing
the internal state of the object within the test.
Depending on the test this is "usually" ok because the mock is typically being
used simply to orchestrate callable methods and not used as a "real" view
(who's behavior may have been changed as a result of NOT calling its own
internal methods).
Original comment by j...@sharethis.com
on 11 Dec 2013 at 1:15
Original issue reported on code.google.com by
jun.n...@gmail.com
on 25 Sep 2013 at 11:04