I'm having problems running tests in IntelliJ using Robolectric and it looks like jMockit might be a factor. My test itself has absolutely no jmockit and in fact the test is now just comparing two strings. I'm working with a large codebase that relies pretty heavily on jmockit, so I think there's an issue with the classpath having jmockit. (I saw something similar but not the same at can jmockit and robolectric coexist?)
Is there a way to work around this? Am I going to have to blow away all my jmockit tests?
The test code is:
@RunWith(RobolectricTestRunner.class)
public class DefaultAssetFormatterTest {
@Test
public void test_asset_formatter() {
assertThat("12345", equalTo("Fsdafadsf"));
}
}
This is what I see when I run the test in IntelliJ:
java.lang.IllegalArgumentException: Failure to invoke method: public static void mockit.integration.junit4.internal.MockFrameworkMethod.validatePublicVoidNoArg(mockit.Invocation,boolean,java.util.List)
at mockit.internal.util.MethodReflection.invoke(MethodReflection.java:61)
at mockit.internal.annotations.MockMethodBridge.callMock(MockMethodBridge.java:76)
at mockit.internal.annotations.MockMethodBridge.invoke(MockMethodBridge.java:41)
at org.junit.runners.model.FrameworkMethod.validatePublicVoidNoArg(FrameworkMethod.java)
at org.junit.runners.ParentRunner.validatePublicVoidNoArgMethods(ParentRunner.java:131)
at org.junit.runners.BlockJUnit4ClassRunner.validateInstanceMethods(BlockJUnit4ClassRunner.java:162)
at org.junit.runners.BlockJUnit4ClassRunner.collectInitializationErrors(BlockJUnit4ClassRunner.java:102)
at org.junit.runners.ParentRunner.validate(ParentRunner.java:344)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:74)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:55)
at org.robolectric.RobolectricTestRunner$HelperTestRunner.<init>(RobolectricTestRunner.java:643)
at org.robolectric.RobolectricTestRunner.getHelperTestRunner(RobolectricTestRunner.java:261)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:194)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:175)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at org.robolectric.RobolectricTestRunner$HelperTestRunner.<init>(RobolectricTestRunner.java:643)
at org.robolectric.RobolectricTestRunner.getHelperTestRunner(RobolectricTestRunner.java:261)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:194)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:175)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
... 2 more
java.lang.IllegalArgumentException: No compatible method found: fireTestRunFinished(mockit.Invocation, org.junit.runner.Result)
at mockit.internal.util.MethodReflection.findCompatibleMethod(MethodReflection.java:138)
at mockit.internal.annotations.MockState.getMockMethod(MockState.java:112)
at mockit.internal.annotations.AnnotatedMockStates.getMockMethod(AnnotatedMockStates.java:109)
at mockit.internal.annotations.MockMethodBridge.callMock(MockMethodBridge.java:65)
at mockit.internal.annotations.MockMethodBridge.invoke(MockMethodBridge.java:41)
at org.junit.runner.notification.RunNotifier.fireTestRunFinished(RunNotifier.java)
at org.junit.runner.JUnitCore.run(JUnitCore.java:158)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)