Ich bekomme seltsame Ausnahme, wenn ich versuche, meine Anwendungsklasse über Roboclectric auszuführen. Ich bin seit mehreren Stunden darauf festgefahren. Könnte mir bitte jemand helfen?Fehler in der Anwendungsklasse während des Komponententests erhalten
java.lang.RuntimeException: Stub!
at android.test.ApplicationTestCase.__constructor__(ApplicationTestCase.java:5)
at android.test.ApplicationTestCase.<init>(ApplicationTestCase.java)
at com.grapplemobile.tmcplus.TmcPlusApplicationTest.<init>(TmcPlusApplicationTest.java:26)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.robolectric.RobolectricTestRunner$HelperTestRunner.createTest(RobolectricTestRunner.java:520)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.robolectric.RobolectricTestRunner$HelperTestRunner.methodBlock(RobolectricTestRunner.java:530)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:247)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:188)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:54)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:152)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
My-Code folgt: Mein Code-Schnipsel ist unten angegeben
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class,sdk = 18)
public class MyApplicationTest extends ApplicationTestCase<MyApplication>{
private MyApplication application;
public MyApplicationTest()
{
super(MyApplication.class);
}
@Before
public void setUp() throws Exception {
// super.setUp();
createApplication();
application = getApplication();
}
@Test
public void testonCreate() throws Exception {
application.onCreate();
}
Bitte entfernen Sie "erweitert ApplicationTestCase". Sie führen es bereits von JVM aus und nicht auf dem Gerät. Richtig? –
@EugenMartynov: Ja, ich betreibe es von JVM. Ich brauche eine Anwendungsinstanz für meine Testfälle, die null wird. Also habe ich gesucht, dass createApplication() Anwendungsinstanz erstellen wird. Wenn ich ApplicationTestCase entfernen werde, wie würde ich dann eine Anwendungsinstanz bekommen? –
Ja, Sie schreiben Danke! –