Android测试测试的测试覆盖率报告

时间:2016-02-12 15:55:06

标签: java android android-gradle build.gradle

我正在尝试为Android集成测试生成测试覆盖率报告并关注博客,但它并没有帮助我。基本上我有jacoco.gradle文件,这是

apply plugin: 'jacoco'

check.dependsOn 'jacoco'

jacoco {
    toolVersion = "0.7.1.201405082137"
}

def coverageSourceDirs = [
        'src/main/java',
]

def coverageExcludedDirs = [
        '**/R*.class',
        '**/BuildConfig*.class',
        '**/*Exception.class',
        '**/*$InjectAdapter.class',
        '**/*$ModuleAdapter.class',
        '**/*$ViewInjector*.class',
        '**/sdk/*Json.class',
        '**/sdk/*Service.class',
        '**/sdk/PRNGFixes.class',
        '**/sdk/*$LinuxPRNGSecureRandom.class'
]

def coverageDir = './build/intermediates/classes/debug'

task jacoco(type: JacocoReport, dependsOn: "test") {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."

    reports {
        xml.enabled = true
        xml.destination = "${buildDir}/reports/jacoco/jacoco.xml"
        html.enabled = true
        html.destination = "${buildDir}/reports/jacoco/html"
    }

    classDirectories = fileTree(
            dir: coverageDir,
            excludes: coverageExcludedDirs
    )
    sourceDirectories = files(coverageSourceDirs)
    executionData = files("$buildDir/jacoco/testDebug.exec")
}

然后我有我的集成测试站点的目录。

integration_test --src / androidTest / java / com / testPackage

在build.gradle中

apply from: '../../config/jacoco/jacoco.gradle'

buildTypes {
        release {
            minifyEnabled false
        }
        debug {
            testCoverageEnabled = true
        }
    }

 sourceSets {
        androidTest {
            setRoot('src/androidTest')
        }
    }

当我运行gradle jacoco任务时,它不会在build / report文件夹中生成测试覆盖率报告。你能告诉我吗?

0 个答案:

没有答案