Mockito使用中遇到的问题
2018-01-10 11:03
316 查看
使用GreenDao时报NullPointerException
解决办法:在类中添加RunWith注解:@RunWith(RobolectricGradleTestRunner.class) @Config(constants = BuildConfig.class, sdk = 16)
Multi dex installation failed
java.lang.RuntimeException: java.lang.RuntimeException: Multi dex installation failed (/Users/me/Data/Projects/my-android/myapp/. (Is a directory)). at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:257) 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:194) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 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:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:355) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)
解决办法:在build.gradle中添加如下依赖:
testCompile "org.robolectric:shadows-multidex:3.0"
build/intermediates/bundles/debug/AndroidManifest.xml not found
Caused by: java.lang.RuntimeException: build/intermediates/bundles/debug/AndroidManifest.xml not found or not a file; it should point to your project's AndroidManifest.xml at org.robolectric.manifest.AndroidManifest.validate(AndroidManifest.java:120) at org.robolectric.manifest.AndroidManifest.getResourcePath(AndroidManifest.java:469) at org.robolectric.manifest.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:475) at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:479) at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:471) at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:73) at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:421) at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:234)
解决办法:
1、 Edit Configurations 2、 In Junit, you have to change the working directory to $MODULE_DIR$
相关文章推荐
- PowerMock使用遇到的问题——2
- 使用Eclipse写Mockito单元测试的问题
- 遇到 Web Server 中不能使用 XmlSerializer 的问题
- 使用vs.net遇到的问题
- Java使用Oracle遇到的最大游标超出问题及其解决方法
- 使用Wallop 遇到的问题
- 今天开始使用这个blog来记录我的学习中遇到的问题吧
- 在IIS 6 中使用HTTP压缩(Compression)遇到的一个问题
- VC6使用过程中遇到的问题收集(1) zz
- 使用System.IO.StreamReader时遇到的问题 (转)
- 使用Oracle中fileopen命令加载文件时遇到的怪问题
- 关于您提到使用WebServices时候遇到“基础连接以关闭”的问题
- 使用WebServices时候遇到“基础连接以关闭”的问题
- datagrid中使用dropdownlist编辑模版时遇到问题
- VC6使用过程中遇到的问题收集(1)
- 在使用BizTalk时遇到一个很郁闷的问题 之解决篇
- 刚才遇到了关于C#使用外部DLL函数上的char*的问题。
- 在MIDAS中使用SocketConnection遇到的问题
- 使用Access存储Session,遇到了SessionId问题?
- 使用SqlParameter参数返回值时遇到的问题