Search code examples
androidtestingeasymock

Android Easy Mock test Error


I am writing a test using Easy Mock and I get this error. I have added all the required jar files Objenesis and Cglib.

Can anyone tell me why I am getting this error?

    java.lang.NoClassDefFoundError: org.easymock.EasyMock
    at de.uitool.commons.api.model.IconTextActionViewFactoryImplTest.setUp(IconTextActionViewFactoryImplTest.java:26)
   at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
   at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
   at    android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:537)
   at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)

My setUp() method:

    protected void setUp() throws Exception {
    super.setUp();
    actionHandlerProvider = EasyMock.createMock(ActionHandlerProvider.class);
    }

Solution

  • I have found this solution for setting up AndroidMock. You can download the required jar files and also a pdf which shows the required steps to set up mock tests for android.

    Android Mock