单元测试-Android-Assertj Android-运行错误



我试图运行assertj android,但它发送了一个错误。(与junit 4运行良好)

我的依赖项:

dependencies {
    testCompile 'junit:junit:4.12'
    androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0'){
        exclude group:'com.android.support', module:'support-annotations'
    }
}

我的构建类型:

buildTypes {
    debug {
        signingConfig signingConfigs.debug
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

我的程序规则.pro:

## Assertj
-dontwarn org.assertj.**
-keep class org.assertj.** {*;}

我在运行中遇到了这个错误:

:app:proguardDebugAndroidTest
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find superclass or interface org.junit.rules.TestRule
Warning:org.assertj.core.api.JUnitSoftAssertions$1: can't find superclass or interface org.junit.runners.model.Statement
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find referenced class org.junit.rules.TestRule
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find referenced class org.junit.runners.model.Statement
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find referenced class org.junit.runner.Description
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find referenced class org.junit.runners.model.Statement
Warning:org.assertj.core.api.JUnitSoftAssertions: can't find referenced class org.junit.runner.Description
Warning:org.assertj.core.api.JUnitSoftAssertions$1: can't find referenced class org.junit.runners.model.Statement
Warning:org.assertj.core.api.JUnitSoftAssertions$1: can't find referenced class org.junit.runners.model.MultipleFailureException
Warning:org.assertj.core.api.JUnitSoftAssertions$1: can't find referenced class org.junit.runners.model.Statement
Warning:org.assertj.core.internal.JavaBeanDescriptor: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.internal.PropertySupport: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.internal.cglib.core.DebuggingClassWriter$1: can't find referenced class org.assertj.core.internal.cglib.asm.util.TraceClassVisitor
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.IntrospectionException
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.Introspector
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.BeanInfo
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.BeanInfo
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.internal.cglib.core.ReflectUtils: can't find referenced class java.beans.IntrospectionException
Warning:org.assertj.core.util.introspection.Introspection: can't find referenced class java.beans.Introspector
Warning:org.assertj.core.util.introspection.Introspection: can't find referenced class java.beans.BeanInfo
Warning:org.assertj.core.util.introspection.Introspection: can't find referenced class java.beans.PropertyDescriptor
Warning:org.assertj.core.util.introspection.Introspection: can't find referenced class java.beans.BeanInfo
Warning:org.assertj.core.util.xml.XmlStringPrettyFormatter: can't find referenced class org.w3c.dom.bootstrap.DOMImplementationRegistry
Warning:there were 59 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
:app:proguardDebugAndroidTest FAILED
:app:newRelicDeinstrumentTask
[newrelic.info] Deinstrumenting...
Error:Execution failed for task ':app:proguardDebugAndroidTest'.
> java.io.IOException: Please correct the above warnings first.

为什么?

基于Proguard 1.2.0版本,并发布在stackoverflow中。

我需要将testProguardFiles添加到我的调试buildType中,因为测试忽略了proguardFiles属性,所以它忽略了我的proguard设置:

buildTypes {
        debug {
            signingConfig signingConfigs.debug
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro'
            testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard-rules-debug.pro'"true"
        }
}

我的proguard文件:

## Assertj
-dontwarn org.assertj.core.**
-dontwarn org.junit.**
-dontwarn java.beans.**

最新更新