JsonChao / Awesome-WanAndroid

:zap:致力于打造一款极致体验的 http://www.wanandroid.com/ 客户端,知识和美是可以并存的哦QAQn(*≧▽≦*)n
Apache License 2.0
2.73k stars 605 forks source link

代码的单元测试报错 #91

Closed linxinghuang closed 5 years ago

linxinghuang commented 5 years ago

单元测试的代码都报同一个错误, LeakCanary内部空指针?

java.lang.NullPointerException at com.squareup.leakcanary.internal.LeakCanaryInternals.isInServiceProcess(LeakCanaryInternals.java:114) at com.squareup.leakcanary.LeakCanary.isInAnalyzerProcess(LeakCanary.java:182) at json.chao.com.wanandroid.app.WanAndroidApp.onCreate(WanAndroidApp.java:94) at org.robolectric.android.internal.ParallelUniverse.lambda$setUpApplicationState$0(ParallelUniverse.java:208) at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:72) at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:207) at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:335) at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:245) at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130) at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42) 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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84) 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:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

JsonChao commented 5 years ago

Thank your issue,单元测试时要把LeakCanary这块注释掉~