unified-code-coverage-android icon indicating copy to clipboard operation
unified-code-coverage-android copied to clipboard

Consider adding multilple flavors to the app

Open yuriykulikov opened this issue 6 years ago • 1 comments

Great guide and examples! Thank you!

I think the example can benefit from adding multiple flavors, or at least some comments related to them. Unfortunately, jacoco does not provide any error messages if folders with execution data are empty or non-existent. This will be the case if a multi-flavor app is tested. Some adjustments are required to the paths:

val javaClasses = fileTree("dir" to "$buildDir/intermediates/javac/developDebug", "excludes" to fileFilter)
val kotlinClasses = fileTree("dir" to "$buildDir/tmp/kotlin-classes/developDebug", "excludes" to fileFilter)
val mainSrc = "$projectDir/src/main/java"

sourceDirectories.setFrom(files(listOf(mainSrc)))
classDirectories.setFrom(files(listOf(javaClasses, kotlinClasses)))
executionData.setFrom(fileTree(
        "dir" to project.buildDir,
        "includes" to listOf(
                "jacoco/testDevelopDebugUnitTest.exec",
                "outputs/code_coverage/developDebugAndroidTest/connected/**/*.ec"
        )
))

yuriykulikov avatar Apr 22 '19 21:04 yuriykulikov

As you can see, "debug" must be replaced by "developDebug", where "develop" is the name of the flavor which will be used for testing.

yuriykulikov avatar Apr 22 '19 21:04 yuriykulikov