Victor Ronin
Victor Ronin

Reputation: 23268

EasyMock + Roboelectric + mocks for class

I am trying to write some unittests for Android and I have following combination:

1) Roboectric (I want to run tests on JVM vs Dalvik)

2) EasyMock (I need to mock classes/interfaces)

3) I want to mock a class.

It works great if I use EasyMock 3.1. It wasn't Android aware, so it happily used cglib stuff and creates bytecode for JVM and create a mock for a class (the same way as it will do this for any non Android app).

However, if I switch to EasyMock 3.2 then it doesn work. It starts giving "ClassNotFoundException". And I feel like it's confused. On one hand, it sees that it's Android environment so probably it does something Android related. On other hand, because of Roboelectric, it runs on JVM (vs Dalvik).

Do you know how to turn off Android awareness in EasyMock 3.2 or higher to get rid of this issue?

Upvotes: 1

Views: 200

Answers (1)

Eugen Martynov
Eugen Martynov

Reputation: 20130

Looking to jira.codehaus.org/browse/EASYMOCK-108 they added Android support to run test with easymock as part of instrumental tests. My suggestions:

  1. silly - if you really don't need 3.2 stay on 3.1
  2. if you use maven or gradle - examine dependencies for easymock and try exlude "dexmaker"
  3. another silly - use mockito

Upvotes: 1

Related Questions