ฉันกำลังพยายามใช้ JMockit 1.5 กับ robolectric 2.2 แต่ฉันได้รับ java.lang.NoSuchMethodException ทันทีที่ฉันพยายามสร้างกิจกรรม ฉันได้ลดการทดสอบลงเหลือเพียง:
@RunWith(RobolectricTestRunner.class)
//@RunWith(MyTestRunner.class)
public class Test_login {
@Test
public void test_login(@Mocked final Intent in) {
FragmentActivity frag = Robolectric.buildActivity(MainActivity.class).create().get();
}
}
แต่ฉันได้รับการติดตามสแต็กนี้:
java.lang.RuntimeException: java.lang.NoSuchMethodException: org.udg.pds.simpleapp_android.roboelectric.Test_login.test_login()
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:201)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:175)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
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:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.NoSuchMethodException: org.udg.pds.simpleapp_android.roboelectric.Test_login.test_login()
at java.lang.Class.getMethod(Class.java:1665)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:199)
... 19 more
ฉันได้ลองใช้นักวิ่งนี้ด้วย:
public class MyTestRunner extends RobolectricTestRunner {
static { Startup.initializeIfPossible(); }
public MyTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
}
แต่มันไม่ได้สร้างความแตกต่าง ฉันได้ลองคำสั่งที่แตกต่างกันกับ classpath (jmockit, robolectric, junit) โดยไม่มีโชค ทันทีที่ฉันพยายามใช้ @Injectable หรือ @Mocked ในการทดสอบ ฉันจะได้รับข้อยกเว้นนี้ ฉันได้อ่านสิ่งนี้ และ สิ่งนี้ แต่ก็ไม่ได้ช่วยอะไร
มีคำใบ้ว่าปัญหาอยู่ที่ไหน? ขอบคุณ