【问题标题】:Can't add JUnit to test and androidTest无法将 JUnit 添加到测试和 androidTest
【发布时间】:2017-04-24 07:37:56
【问题描述】:

我在两个测试文件夹中都需要 JUnit。所以我加了

androidTestCompile 'junit:junit:4.12'
testCompile 'junit:junit:4.12'

但是,一旦我将 JUnit 添加到 androidTest,我就无法运行测试,因为抛出的错误in this log.

关于如何解决这个问题的任何想法?

编辑:我从运行配置中删除了 gradle-aware 构建。现在它说我的TestSuite 是空的,但是有测试用@Test 注释

【问题讨论】:

    标签: android junit android-testing


    【解决方案1】:

    在你的 build.gradle 文件中尝试一下

    dependencies {   
    
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
    
        testCompile 'junit:junit:4.12'
    
    }
    

    【讨论】:

    • 那么 espresso 包含 JUnit 吗?
    • 几乎相同的堆栈跟踪
    • 我不知道。它由 android studio 自动创建。并解决我的 Junit 测试问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-19
    • 2013-11-04
    • 1970-01-01
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多