当我尝试运行JUnit测试类时遇到问题
java.lang.RuntimeException: java.lang.IllegalArgumentException: App ID length must be 32 characters.
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:244)
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:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
引起:java.lang.IllegalArgumentException:App ID长度必须为32个字符。
at net.hockeyapp.android.utils.Util.sanitizeAppIdentifier(Util.java:127)
at net.hockeyapp.android.CrashManager.initialize(CrashManager.java:490)
at net.hockeyapp.android.CrashManager.register(CrashManager.java:124)
at net.hockeyapp.android.CrashManager.register(CrashManager.java:97)
at net.hockeyapp.android.CrashManager.register(CrashManager.java:85)
at app.fabhotels.FabHotelApp.checkForCrashes(FabHotelApp.java:64)
答案 0 :(得分:2)
您似乎正在CrashManager
的{{1}}内安装onCreate()
。
如果您有一个复杂的Application
类,则可能不适合在您的Robolectric测试中使用它。
一种解决方案是创建一个空的Application
类:
Application
然后您的测试设置可能如下所示:
public void EmptyApp extends Application {
}