在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):palantir/gradle-jacoco-coverage开源软件地址(OpenSource Url):https://github.com/palantir/gradle-jacoco-coverage开源编程语言(OpenSource Language):Groovy 91.2%开源软件介绍(OpenSource Introduction):Note: This plugin is considered obsolete as of Gradle 3.4 which supports coverage enforcement as part of the core JaCoCo plugin. Jacoco Coverage Gradle PluginJacoco Coverage is a Gradle Plugin that provides two tasks extending the standard Gradle Jacoco plugin:
Release and change logs: CHANGELOG.md Source code: https://github.com/palantir/gradle-jacoco-coverage com.palantir.jacoco-coverageQuick startAdd the following configuration to buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.palantir:jacoco-coverage:<version>'
}
}
apply plugin: 'java'
apply plugin: 'com.palantir.jacoco-coverage'
jacocoCoverage {
// Enforce minimum code coverage of 50% for every Java file.
fileThreshold 0.5
// Whitelist files named MyClass.java from coverage requirements.
fileThreshold 0.0, "MyClass.java"
} Subsequent ConfigurationCode coverage requirements are specified separately for the different "realms" reported by Jacoco:
Each realm contains a number of so-called "scopes":
Scopes can be specified by exact name, e.g., Configuration syntaxCoverage requirements are written in terms of a realm, a scope specification, and one (or several) of the Jacoco-defined types of coverage, e.g., lines covered or branches covered. The following syntax variations are supported:
, where:
Examples: jacocoCoverage {
// Minimum code coverage of 50% for all scopes in the file realm (i.e., for all files) and for all coverage types.
fileThreshold 0.5
// Minimum 'branch' coverage of 30% for all files.
fileThreshold 0.3, BRANCH
// Minimum 'line' coverage of 10% for files (in any directory) whose name matches the given regular expression.
fileThreshold 0.1, LINE, ~"(Indentation|Wrapping)\\.java"
// Minimum 'line' coverage of 10% for files named "Indentation.java" (case-sensitive, in any directory).
// (Note: This syntax uses exact string match against the file name while the regex syntax requires escaping.)
fileThreshold 0.1, LINE, "Indentation.java"
// Minimum coverage of 30% in the given class.
classThreshold 0.3, "org/company/module/MyClass"
// Minimum average coverage of 30% in given package.
packageThreshold 0.3, "org/company/module"
// Minimum average coverage of 50% in report "my-project; the report name is usually the Gradle project name.
reportThreshold 0.5, "my-project"
// Scopes can be exempt from all coverage requirements by exact scope name or scope name pattern.
fileThreshold 0.0, "MyClass.java"
packageThreshold 0.0, "org/company/module"
fileThreshold 0.0, ~".*Test.java"
} Configuration semanticsGiven the observed code coverage for a realm, scope, and coverage type (e.g., line coverage 47% for class
jacocoCoverage {
classThreshold 0.5, BRANCH
classThreshold 0.3, "org/company/module/MyClass"
} will enforce 50% branch coverage for every class, and 30% coverage for class jacocoCoverage {
packageThreshold 0.0, BRANCH // Never enforce branch coverage at the package level
fileThreshold 0.0, ~".*Util\\.java" // Never enforce coverage on Java files like XyzUtil.java
packageThreshold 0.0, ~"org/thirdparty/.*" // Never enforce coverage on thirdparty package.
} com.palantir.jacoco-full-reportQuickstartAdd the following configuration to the buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.palantir:jacoco-coverage:<version>'
}
}
apply plugin: 'com.palantir.jacoco-full-report' // Automatically applies the 'jacoco' plugin to this project. Subsequent ConfigurationThe By default, Jacoco report tasks of all projects and subprojects are considered when compiling the full report. Projects
can be excluded from consideration through the jacocoFull {
excludeProject ":my-sub-project", ":buildSrc"
} Note that |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论