0
我在努力学习Robolectric
。所以我正在测试在Eclipse上创建的应用程序。 该项目使用Parse-1.7.1.jar
接收推送通知。我按照这些instructions设置了robolectric。然而,当我尝试运行测试我得到这个异常:Robolectric和外部罐子
java.lang.IllegalStateException: In order to use the ParsePush.subscribe or ParsePush.unsubscribe methods you must add the following to your AndroidManifest.xml:
<receiver android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.OPEN" />
<action android:name="com.parse.push.intent.DELETE" />
</intent-filter>
</receiver>
(Replace "com.parse.ParsePushBroadcastReceiver" with your own implementation if you choose to extend ParsePushBroadcastReceiver)
at com.parse.ParsePush.checkForManifestAndThrowExceptionIfNeeded(ParsePush.java:152)
at com.parse.ParsePush.subscribeInBackground(ParsePush.java:78)
at com.parse.ParsePush.subscribeInBackground(ParsePush.java:99)
at mx.com.ronda.test.RondaApplication.onCreate(RondaApplication.java:25)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:126)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:440)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:222)
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:158)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
我的Android项目上没有明显宣布ParsePushBroadcastReceiver
因为我扩展它。我尝试将Parse作为外部jar添加到我的测试java项目(属性> java构建路径>库>添加外部jar),但它不起作用。
让我知道你是否需要更多信息。我希望你能帮助我。
OMG它的工作!非常感谢。最后一件事,请告诉我为什么可行,或者指出解释该文档的文档? – ILovemyPoncho
老实说,我不知道为什么ParsePush不起作用,我仍在深入研究。如果我在这件事上发现了什么,我会在这里编辑我的答案并留下评论! – Leonardo
再次感谢Leo – ILovemyPoncho