I'm trying to implement a unit test using Robolectric to replace the stubbed methods in android.jar while also using jMockit to mock an Android class (Fragment, in my case). However, I can't seem to get it to work. If I annotate the test class with @RunWith(RobolectricTestRunner.class)
, I get:
java.lang.IllegalStateException: JMockit wasn't properly initialized; check that jmockit.jar precedes junit.jar in the classpath (if using JUnit; if not, check the documentation)
If I use @RunWith(JMockit.class)
or no @RunWith
, I get "Stub!" exceptions.
At the moment, my classpath has things in the following order: robolectric, jmockit, junit, android.
Anybody out there been able to get jmockit and robolectric to play well together?