测试在Android Studio中正常运行,但在使用Gradle在CLI上运行测试时却没有。我猜测类路径的东西。这是堆栈跟踪。有什么想法吗?
我使用robolectric 3.3.2或3.4-rc1和3.4-rc1获得相同的结果
java.lang.RuntimeException: java.lang.NullPointerException
at
org.robolectric.res.ResourceTableFactory.parseResourceFiles
(ResourceTableFactory.java:155)
at
org.robolectric.res.ResourceTableFactory.newResourceTable
(ResourceTableFactory.java:43)
at org.robolectric.res.ResourceMerger.buildResourceTable
(ResourceMerger.java:22)
at org.robolectric.RobolectricTestRunner.getAppResourceTable
(RobolectricTestRunner.java:450)
at org.robolectric.RobolectricTestRunner.beforeTest
(RobolectricTestRunner.java:288)
at org.robolectric.internal.SandboxTestRunner$2.evaluate
(SandboxTestRunner.java:203)
at org.robolectric.internal.SandboxTestRunner.runChild
(SandboxTestRunner.java:109)
at org.robolectric.internal.SandboxTestRunner.runChild
(SandboxTestRunner.java:36)
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:63)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter
.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter
.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor
.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor
.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch
(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch
(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch
(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter
$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy1.processTestClass(Unknown Source)
at
org.gradle.api.internal.tasks.testing.worker.TestWorker
.processTestClass(TestWorker.java:109)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch
(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch
(ReflectionDispatch.java:24)
at
org.gradle.internal.remote.internal.hub
.MessageHubBackedObjectConnection
$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
at org.gradle.internal.remote.internal.hub.
MessageHubBackedObjectConnection$DispatchWrapper.dispatch
(MessageHubBackedObjectConnection.java:128)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run
(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures
.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run
(StoppableExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl
$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.robolectric.res.DocumentLoader.loadFile(DocumentLoader.java:35)
at org.robolectric.res.DocumentLoader.load(DocumentLoader.java:26)
at org.robolectric.res.ResourceTableFactory.parseResourceFiles
(ResourceTableFactory.java:140)
... 41 more