GithubHelp home page GithubHelp logo

dlethin / gradle-clover-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bmuschko/gradle-clover-plugin

1.0 2.0 0.0 144 KB

Gradle plugin for generating a code coverage report using Clover

License: Apache License 2.0

Shell 17.19% Groovy 82.81%

gradle-clover-plugin's Introduction

Gradle Clover plugin

Clover Logo

The plugin provides generation of code coverage reports using Clover.

Usage

To use the Clover plugin, include in your build script:

apply plugin: 'clover'

The plugin JAR needs to be defined in the classpath of your build script. You can either get the plugin from the GitHub download section or upload it to your local repository. To define the Clover dependency please use the testRuntime configuration name in your dependencies closure.

buildscript {
    repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'GitHub'
            addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }

    dependencies {
        classpath 'bmuschko:gradle-clover-plugin:0.3'
    }
}

dependencies {
    testRuntime 'com.cenqua.clover:clover:3.1.0'
}

Tasks

The Clover plugin defines the following tasks:

  • cloverGenerateReport: Generates Clover code coverage report.
  • cloverAggregateReports: Aggregate Clover code coverage reports in a multi-module project setup. This task can only be run from the root directory of your project and requires at least one submodule.

Convention properties

  • initString: The location to write the Clover coverage database (defaults to .clover/clover.db). The location you define will always be relative to the project's build directory.
  • classesBackupDir: The temporary backup directory for classes (defaults to file("${sourceSets.main.classesDir}-bak")).
  • licenseFile: The Clover license file to be used (defaults to file('clover.license')).
  • includes: A list of String Ant Glob Patterns to include for instrumentation (defaults to '**/*.java' for Java projects, defaults to '**/*.java' and '**/*.groovy' for Groovy projects).
  • excludes: A list of String Ant Glob Patterns to exclude for instrumentation. By default no files are excluded.
  • testIncludes: A list of String Ant Glob Patterns to include for instrumentation for per-test coverge (defaults to '**/*Test.java' for Java projects, defaults to '**/*Test.java' and '**/*Test.groovy' for Groovy projects).
  • targetPercentage: The required target percentage total coverage e.g. "10%". The build fails if that goals is not met. If not specified no target percentage will be checked.

Within clover you can define coverage contexts in a closure named contexts. There are two types of coverage contexts: statement contexts and method contexts. You can define as many contexts as you want. Each of the context type closure define the following attributes:

  • name: A unique name that identifies the context. If you want to apply the context to your report you got to use this name as part of report filter attribute.
  • regexp: The specified structure or pattern that matches a context as part of the instrumented source code. Make sure that you correctly escape special characters.

Within clover you can define which report types should be generated in a closure named report:

  • xml: Generates XML report (defaults to true).
  • json: Generates JSON report (defaults to false).
  • html: Generates HTML report (defaults to false).
  • pdf: Generates PDF report (defaults to false).
  • filter: A comma or space separated list of contexts to exclude when generating coverage reports. See Using Coverage Contexts. By default no filter is applied.

The Clover plugin defines the following convention properties in the clover closure:

Example

clover {
    classesBackupDir = file("${sourceSets.main.classesDir}-backup")
    licenseFile = file('clover-license.txt')
    excludes = ['**/SynchronizedMultiValueMap.java']
    targetPercentage = '85%'

    contexts {
        statement {
            name = 'log'
            regexp = '^.*LOG\\..*'
        }

        method {
            name = 'main'
            regexp = 'public static void main\\(String args\\[\\]\\).*'
        }
    }

    report {
        html = true
        pdf = true
        filter = 'log,if,else'
    }
}

gradle-clover-plugin's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.