2015-06-19 77 views
2

我運行到哪裏我robolectric測試在我的終端傳遞方面的問題: ./gradlew test 和相同的命令,正確與circleci所有工具配置給了我這個錯誤:Robolectric在CI環境

java.lang.RuntimeException: java.lang.IllegalArgumentException: maxSize <= 0 
     at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:238) 
     at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:185) 
     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:149) 
     at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86) 
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49) 
     at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69) 
     at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48) 
     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:497) 
     at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
     at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
     at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) 
     at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) 
     at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) 
     at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105) 
     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:497) 
     at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) 
     at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) 
     at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)  
     at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.IllegalArgumentException: maxSize <= 0 
     at com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache.<init>(LruMemoryCache.java:33) 
     at com.nostra13.universalimageloader.core.DefaultConfigurationFactory.createMemoryCache(DefaultConfigurationFactory.java:114) 
     at com.nostra13.universalimageloader.core.ImageLoaderConfiguration$Builder.initEmptyFieldsWithDefaultValues(ImageLoaderConfiguration.java:584) 
     at com.nostra13.universalimageloader.core.ImageLoaderConfiguration$Builder.build(ImageLoaderConfiguration.java:559) 
     at com.heetch.HeetchApp.initImageLoader(HeetchApp.java:123) 
     at com.heetch.HeetchApp.onCreate(HeetchApp.java:55) 
     at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:140) 
     at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421) 
     at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234) 
     ... 34 more 

我使用robolectric 3.0-rc3,我相信這個bug來自robolectric本身,但我沒有任何線索在哪裏尋找解決這個錯誤。

+1

貴堆棧跟蹤有一個由部分引起的,你不貼? – nenick

+0

@nenick我更新到堆棧跟蹤到完整的輸出 –

+0

HeetchApp.initImageLoader(HeetchApp.java:123)的內容可能很有趣。這是否可以在AndroidStudio中使用?原因是createMemoryCache將被緩存大小調整爲<​​= 0.這個緩存大小是否由您的應用程序類設置?當是的時候/你如何得到尺寸值? – nenick

回答

2

的解決方案是一個內存緩存添加到ImageLoader的,如下:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this) 
       .memoryCache(new WeakMemoryCache()) 
       .build();