模拟测试测试的最终课程 - Gradle问题

时间:2015-12-17 16:55:06

标签: android junit powermock

我正在尝试使用Powermock来模拟静态类。 这是我的gradle文件依赖项:

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.mockito:mockito-core:1.+'
androidTestCompile 'org.mockito:mockito-core:1.+'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
androidTestCompile 'com.android.support:support-annotations:23.0.1'
androidTestCompile 'com.android.support.test:runner:0.4.1'
androidTestCompile 'com.android.support.test:rules:0.4'

androidTestCompile 'org.powermock:powermock-api-mockito:1.6.2'
androidTestCompile 'org.powermock:powermock-module-junit4-rule-agent:1.6.2'
androidTestCompile 'org.powermock:powermock-module-junit4-rule:1.6.2'
androidTestCompile 'org.powermock:powermock-module-junit4:1.6.2'

}

问题是,一旦我运行测试,我会收到以下错误:

  

:应用程序:preDexDebugAndroidTest   AGPBI:{" kind":"简单","文字":"拿起_JAVA_OPTIONS:-Djava.net.preferIPv4Stack \ u003dtrue", "来源":[{}]}

     

AGPBI:{" kind":"简单","文字":"拿起_JAVA_OPTIONS:-Djava.net.preferIPv4Stack \ u003dtrue&# 34;,"来源":[{}]}

     

AGPBI:{" kind":"简单","文字":"拿起_JAVA_OPTIONS:-Djava.net.preferIPv4Stack \ u003dtrue&# 34;,"来源":[{}]}

     

:应用程序:dexDebugAndroidTest   AGPBI:{" kind":"简单","文字":"意想不到的顶级例外:","来源& #34;:[{}]}   AGPBI:{" kind":" simple"," text":" com.android.dex.DexException:多个dex文件定义Lorg / powermock /模块/ junit4 /规则/ PowerMockRule;""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger。的java:596)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger。的java:554)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger。的java:535)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger。的java:171)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.merge.DexMerger.merge(DexMerger。的java:189)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers( Main.java:502)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.command.dexer.Main.runMonoDex( Main.java:334)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.command.dexer.Main.run( Main.java:277)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.command.dexer.Main.main( Main.java:245)""来源":[{}]}   AGPBI:{" kind":" simple"," text":" \ tat com.android.dx.command.Main.main(Main。的java:106)""来源":[{}]}   AGPBI:{" kind":"简单","文字":"拿起_JAVA_OPTIONS:-Djava.net.preferIPv4Stack \ u003dtrue", "来源":[{}]}

失败:构建因异常而失败。

  • 出了什么问题: 任务执行失败':app:dexDebugAndroidTest'。

      

    com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程'命令' C:\ Program Files \ Java \ jdk1.8.0_60 \ bin \的java.exe''完成非零退出值2

  • 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。

建立失败

请告知根本原因是什么,如何模拟最终的仪器测试类。

由于

0 个答案:

没有答案