Creating coverage for other modules

My project structure is as follows: :app, :core. :appis an Android app project, and it depends on :corewhich has all the business logic.

I have Espressotests for :app, and I can run and get a coverage report thanks to all the questions and guides. But coverage is for code only :app.

How to get coverage for all projects ( :appand :core) received as a result of tests on Espresso? Is it possible?

Any help is greatly appreciated.

+4
source share
2 answers

Jacoco , , , , . Jacquo Gradle (apply plugin: 'jacoco') JacocoReport.

​​, , :

task jacocoTestReport(type: JacocoReport) {
    dependsOn // all your test tasks
    reports {
        xml.enabled = true
        html.enabled = true
    }
    sourceDirectories = // files() or fileTree() to your source files
    classDirectories = // files() or fileTree() to your class files
    executionData = // files() or fileTree() including all your test results
}

Espresso .ec. Gradle , .

Jacoco, , .

+2

JacocoReport . AdditionalSourceDirs JacocoReport.

app/build.gradle

apply plugin: 'java'
apply plugin: 'jacoco'

// tell gradle that :core must be evaluated before :app (so the sourceSets are configured)
evaluationDependsOn(':core') 

jacocoTestReport {
    def coreSourceSet = project(':core').sourceSets.main
    additionalSourceDirs.from coreSourceSet.allJava
    additionalClassDirs.from coreSourceSet.output
}
+1

Source: https://habr.com/ru/post/1673361/


All Articles