首页 > 解决方案 > Kotlin - Android Studio 中的 Java 代码覆盖率显示 0% NOT WORKING

问题描述

在我在 Android 工作室的一个 android 项目中,我有一些用 Kotlin 编写的源文件和用 Java 编写的相应单元测试,现在当我尝试运行覆盖率的测试类时,它显示为 0%。所有测试都通过并运行良好,但覆盖率显示为 0%。

对于用 Java 编写的源文件以及测试类也在 Java 中的情况,它工作得非常好,唯一的问题是源类在 kotlin 中,而测试类在 Java 中,反之亦然。

Gradle Version : 4.1
Kotlin Version : 1.1.61
play_services = "11.8.0"//9.4.0
support_version = "27.1.0"//23.+
espresso = "3.0.1"

testCompile 'junit:junit:4.12'
    //mockito
    testCompile "org.mockito:mockito-core:2.8.9" // PowerMockito works on 2.8.9
    testCompile "org.powermock:powermock-module-junit4:1.7.3"
    testCompile "org.powermock:powermock-api-mockito2:1.7.0RC2"

    androidTestCompile "com.android.support:support-annotations:$support_version"
    androidTestCompile 'com.android.support.test:runner:1.0.1'
    androidTestCompile 'com.android.support.test:rules:1.0.1'
    androidTestCompile "com.android.support.test.espresso:espresso-core:$espresso"
    androidTestCompile "com.android.support.test.espresso:espresso-intents:$espresso"
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
    androidTestCompile 'org.mockito:mockito-android:2.8.9'

任何帮助表示赞赏,如果有人知道如何解决这个问题,请告诉我。谢谢

标签: unit-testingandroid-studio-3.0kotlin-android-extensions

解决方案


推荐阅读