• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

arturdm/jacoco-android-gradle-plugin: Gradle plugin that creates JaCoCo test rep ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

arturdm/jacoco-android-gradle-plugin

开源软件地址(OpenSource Url):

https://github.com/arturdm/jacoco-android-gradle-plugin

开源编程语言(OpenSource Language):

Groovy 87.3%

开源软件介绍(OpenSource Introduction):

jacoco-android-gradle-plugin

Gradle Plugin Portal Build Status codecov

A Gradle plugin that adds fully configured JacocoReport tasks for unit tests of each Android application and library project variant.

Why

In order to generate JaCoCo unit test coverage reports for Android projects you need to create JacocoReport tasks and configure them by providing paths to source code, execution data and compiled classes. It can be troublesome since Android projects can have different flavors and build types thus requiring additional paths to be set. This plugin provides those tasks already configured for you.

Usage

buildscript {
  repositories {
    ...
    maven { url 'https://plugins.gradle.org/m2/' }
  }
  dependencies {
    ...
    classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5'
  }
}

apply plugin: 'com.android.application'
apply plugin: 'com.dicedmelon.gradle.jacoco-android'

jacoco {
  toolVersion = "0.8.4"
}

tasks.withType(Test) {
  jacoco.includeNoLocationClasses = true
}

android {
  ...
  productFlavors {
    free {}
    paid {}
  }
}

The above configuration creates a JacocoReport task for each variant and an additional jacocoTestReport task that runs all of them.

jacocoTestPaidDebugUnitTestReport
jacocoTestFreeDebugUnitTestReport
jacocoTestPaidReleaseUnitTestReport
jacocoTestFreeReleaseUnitTestReport
jacocoTestReport

The plugin excludes Android generated classes from report generation by default. You can use jacocoAndroidUnitTestReport extension to add other exclusion patterns if needed.

jacocoAndroidUnitTestReport {
  excludes += ['**/AutoValue_*.*',
              '**/*JavascriptBridge.class']
}

You can also toggle report generation by type using the extension.

jacocoAndroidUnitTestReport {
  csv.enabled false
  html.enabled true
  xml.enabled true
}

By default your report will be in [root_project]/[project_name]/build/jacoco/ But you can change the local reporting directory :

jacocoAndroidUnitTestReport {
  destination "/path/to/the/new/local/directory/"
}

To generate all reports run:

$ ./gradlew jacocoTestReport

Reports for each variant are available at $buildDir/reports/jacoco in separate subdirectories, e.g. build/reports/jacoco/jacocoTestPaidDebugUnitTestReport.

Examples

Snapshot usage

Snapshots of the development version are available in Sonatype Nexus snapshots repository.

buildscript {
  repositories {
    ...
    maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
  }
  dependencies {
    ...
    classpath 'com.dicedmelon.gradle:jacoco-android:x.y.z-SNAPSHOT'
  }
}

License

Copyright 2015-2021 Artur Stępniewski

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap