运行时错误PowerMock + Mockito:ProxyFrameworkImpl无法位于类路径中 [英] Runtime error PowerMock + Mockito: ProxyFrameworkImpl could not be located in classpath
问题描述
我试图使用PowerMock与Android InstrumentTestCase
因为我的测试在Android设备上运行,所以需要将库添加到apk中。
我遇到了powermock + mockito和Dex文件的大问题。
我的依赖中只有powermock + mockito有一个运行时错误:
pre $ org.powermock.api.extension。 proxyframework.ProxyFrameworkImpl无法位于类路径中。
如果包含cglib / cglib-nodep(在answers ):
com.android.dex.DexException:多个dex文件定义Lnet / sf / cglib / beans / BeanCopier $ BeanCopierKey
下面是我的gradle.build的一部分:
androidTestCompile'com.android .support.test:runner:0.3'
androidTestCompile'org.powermock:powermock-api-mockito:1.6.4'
androidTestCompile'org.powermock:powermock-module-junit4:1.6.4'
androidTestCompile'cglib:cglib-nodep:3.2.0'
androidTestCompile'cglib:cglib:3.2.0'
我缺少什么?
预先致谢!
我也尝试使用PowerMock进行Android仪器测试并获得了stuc k。同样的问题。
以下是我在 PowerMock github
PowerMock在Android上无法运行PowerMock正在使用JVM字节码操作的设备。如果你在JVM上运行它,它就会工作。
所以,我猜PowerMock只适合Android上的单元测试。 / p>
I am trying to use PowerMock with the Android InstrumentTestCase Since my test runs on an Android device the libraries needs to be added to the apk.
I encounter big issues with powermock+mockito and Dex files. I have a runtime error with only powermock+mockito in my dependencies:
org.powermock.api.extension.proxyframework.ProxyFrameworkImpl could not be located in classpath.
And a compilation error if I include either cglib/cglib-nodep (has suggested in answers):
com.android.dex.DexException: Multiple dex files define Lnet/sf/cglib/beans/BeanCopier$BeanCopierKey
Here is a part of my gradle.build:
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'org.powermock:powermock-api-mockito:1.6.4'
androidTestCompile 'org.powermock:powermock-module-junit4:1.6.4'
androidTestCompile 'cglib:cglib-nodep:3.2.0'
androidTestCompile 'cglib:cglib:3.2.0'
What am I missing ?
Thanks in advance!
I also tried to use PowerMock for Android instrumentation tests and got stuck with the same issue.
Here is what I've found on PowerMock github
PowerMock won't work on Android if you run it on a device since PowerMock is using JVM byte code manipulation. It will work if you run it on a JVM though.
So, I guess PowerMock is only appropriate for unit testing on Android.
这篇关于运行时错误PowerMock + Mockito:ProxyFrameworkImpl无法位于类路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!