android jacoco coverage empty with gradle

前端 未结 8 2130
旧巷少年郎
旧巷少年郎 2021-01-12 23:39

I\'m trying to make jacoco create a code coverage report for my android test project. I have the following in build.gradle:

apply plugin: \'com.android.appli         


        
8条回答
  •  生来不讨喜
    2021-01-13 00:11

    Now (Oct 2015) you can use it as android team has fixed the bug.

    android {
        ...
        buildTypes {
            debug {
                testCoverageEnabled true
            }
        }
        ...
        dependencies{
            androidTestCompile 'com.android.support.test:runner:0.4.1'
            // Set this dependency to use JUnit 4 rules
            androidTestCompile 'com.android.support.test:rules:0.4.1'
            // Set this dependency to build and run Espresso tests
            androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
            // Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
            androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.1'
        }
    }
    

    Then just use ./gradlew createDebugCoverageReport.

提交回复
热议问题