Android does not recognize Mockito Noclassdeffounderror

Asked

Viewed 26 times

0

I’m trying to use Mockito to perform tests on an Android app. I copied the following jars for the project: Mockito-all-1.9.5.jar, dexmaker-1.0. jar, dexmaker-Mockito-1.0.jar. Then I added it to Buildpath. Does not generate build error, but when I run the tests, the following error appears:

    java.lang.NoClassDefFoundError: org.mockito.Mockito
at com.example.projetomockito.test.ClienteTest.testExisteCliente(ClienteTest.java:17)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:545)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1551)

Error appears on the following line:

cliente = mock(Cliente.class);
  • You are using Android Studio + Gradle?

  • @sicachester, I’m using Eclipse.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.