如何获得Powermock与Dexmaker工作

编程入门 行业动态 更新时间:2024-10-09 18:23:08
本文介绍了如何获得Powermock与Dexmaker工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想 Powermock 为我的Andr​​oid测试的依赖使用纳入以下的build.gradle配置:

I am trying to incorporate Powermock as a dependency for my Android tests using the following build.gradle configuration:

dependencies{ compile 'com.android.support:appcompat-v7:21.0.+' androidTestCompile('org.mockito:mockito-core:1.9.5') androidTestCompile('com.google.dexmaker:dexmaker:1.2') androidTestCompile('com.google.dexmaker:dexmaker-mockito:1.2') androidTestCompile('org.powermock:powermock-module-junit4:1.5.5') { exclude module: 'junit' } androidTestCompile('org.powermock:powermock-api-mockito:1.5.5') { exclude module: 'mockito-all' } }

不过,编译器抱怨说

However, the compiler is complaining that

Error:Gradle: Execution failed for task ':app:packageDebugTest'. > Duplicate files copied in APK mockito-extensions/org.mockito.plugins.MockMaker File 1: ~/.gradle/caches/modules-2/files-2.1/com.google.dexmaker/dexmaker-mockito/1.2/b99884a4c6ef6335ba376f79aa79632b2421c17c/dexmaker-mockito-1.2.jar File 2: ~/.gradle/caches/modules-2/files-2.1/com.google.dexmaker/dexmaker-mockito/1.2/b99884a4c6ef6335ba376f79aa79632b2421c17c/dexmaker-mockito-1.2.jar

展望罐子结构,我注意到Dexmaker和Powermock都声明了一个 MockMaker 在的Mockito的扩展

什么是MockMaker?它们有什么不同?而最重要的问题:是否有可能得到Powermock与Dexmaker很好地工作。

What is a MockMaker? How do they differ? And the most important question: Is it possible to get Powermock to work nicely with Dexmaker?

在此先感谢。任何帮助将大大AP preciated。

Thanks in advance. Any help would be greatly appreciated.

推荐答案

MockMaker是胶水模块dexmaker与集成的Mockito。它有什么必要要的Mockito与Dalvik的.dex文件,而不是JVM的.class文件生成具体的类。

MockMaker is a glue module that integrates dexmaker with Mockito. It does what's necessary for Mockito to generate concrete classes with Dalvik .dex files instead of JVM .class files.

这可能是Powermock将与Dexmaker工作,但它不可能先进Powermock功能将正常工作。特别是,Powermock 发布此:

It's possible that Powermock will work with Dexmaker, but it's unlikely advanced Powermock features will work. In particular, Powermock advertises this:

的 PowerMock使用自定义类加载器和字节code操作,使静态方法,构造函数,最终的类和方法,私有方法,去除静态初始化和更多的嘲讽。的

这是自定义类加载器是不太可能在dalvikvm工作。

That custom class loader is unlikely to work on dalvikvm.

更多推荐

如何获得Powermock与Dexmaker工作

本文发布于:2023-10-31 06:48:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545334.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   工作   Powermock   Dexmaker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!