android - Mockito AbstractMethodError on initMocks -
so i've been struggling pretty day trying mockito work android project. added gradle build file:
androidtestcompile 'org.mockito:mockito-core:2.0.29-beta' androidtestcompile "junit:junit:4.12-beta-3" androidtestcompile 'com.google.dexmaker:dexmaker:1.2' androidtestcompile 'com.google.dexmaker:dexmaker-mockito:1.2'
and have tried running test doesn't anything:
@runwith(mockitojunitrunner.class) public class loginactivitytest extends activityinstrumentationtestcase2<loginactivity> { private loginactivity loginactivity; private edittext et_email; private edittext et_password; private button btn_login; @mock spicemanager manager; public loginactivitytest(){ super(loginactivity.class); } @override public void setup() throws exception { super.setup(); loginactivity = getactivity(); mockitoannotations.initmocks(this); //manager = mock(spicemanager.class); loginactivity.spicemanager = manager; et_email = (edittext) loginactivity.findviewbyid(r.id.et_email); et_password = (edittext) loginactivity.findviewbyid(r.id.et_password); btn_login = (button) loginactivity.findviewbyid(r.id.btn_login); } @override public void teardown() throws exception { super.teardown(); } public void testloginempty() throws exception { verify(manager).execute( any(loginrequest.class), anystring(), anylong(), any(loginactivity.loginrequestlistener.class)); } }
the reason want mock service because keep network part out test. there's no need send network request simple test, right?
anyhow, app builds when actual test starts running fails (or rather crashes) abstractmethoderror
:
running tests test running started java.lang.abstractmethoderror: abstract method "org.mockito.plugins.mockmaker$typemockability org.mockito.plugins.mockmaker.istypemockable(java.lang.class)" @ org.mockito.internal.util.mockutil.typemockabilityof(mockutil.java:26) @ org.mockito.internal.util.mockcreationvalidator.validatetype(mockcreationvalidator.java:21) @ org.mockito.internal.creation.mocksettingsimpl.validatedsettings(mocksettingsimpl.java:167) @ org.mockito.internal.creation.mocksettingsimpl.confirm(mocksettingsimpl.java:161) @ org.mockito.internal.mockitocore.mock(mockitocore.java:58) @ org.mockito.mockito.mock(mockito.java:1410) @ org.mockito.mockito.mock(mockito.java:1288) @ be.sanmax.membr.activities.loginactivitytest.setup(loginactivitytest.java:50) @ android.test.androidtestrunner.runtest(androidtestrunner.java:191) @ android.test.androidtestrunner.runtest(androidtestrunner.java:176) @ android.test.instrumentationtestrunner.onstart(instrumentationtestrunner.java:555) @ android.app.instrumentation$instrumentationthread.run(instrumentation.java:1837)
this strikes me odd since spicemanager
class not contain abstract
methods. is, however, part of package didn't write (com.octo.android.robospice
). shouldn't issue. should it?
and if issue, how go factoring out tests? want test working of app, not network connection...
dexmaker not support mockito 2.0 since definition of mockmaker
has changed. suggest use mockito 1.10.19 run this npe have submitted fix.
Comments
Post a Comment