Skip to content

Instantly share code, notes, and snippets.

@th-deng
th-deng / build.gradle
Last active Jan 23, 2020
Exclude classes from coverage violation rules
View build.gradle
// groovy DSL
jacocoTestCoverageVerification {
violationRules {
rule {
element = 'CLASS'
limit {
counter = 'LINE'
@th-deng
th-deng / build.gradle
Created Jan 23, 2020
Config coverage validation rules
View build.gradle
// groovy DSL
jacocoTestCoverageVerification {
violationRules {
rule {
// 'element'가 없으면 프로젝트의 전체 파일을 합친 값을 기준으로 한다.
limit {
// 'counter'를 지정하지 않으면 default는 'INSTRUCTION'
// 'value'를 지정하지 않으면 default는 'COVEREDRATIO'
minimum = 0.30
@th-deng
th-deng / build.gradle
Created Jan 23, 2020
Add task ordering
View build.gradle
// groovy DSL
test {
// ... (생략) ...
finalizedBy 'jacocoTestReport'
}
jacocoTestReport {
// ... (생략) ...
@th-deng
th-deng / build.gradle
Last active Jan 23, 2020
Create the task that creates report and verifies coverages
View build.gradle
// groovy DSL
task testCoverage(type: Test) {
group 'verification'
description 'Runs the unit tests with coverage'
dependsOn(':test',
':jacocoTestReport',
':jacocoTestCoverageVerification')
@th-deng
th-deng / build.gradle
Last active Jan 23, 2020
Using JUnitPlatform
View build.gradle
// groovy DSL
test {
useJUnitPlatform()
}
@th-deng
th-deng / build.gradle
Created Jan 23, 2020
Default JacocoTaskExtension settings
View build.gradle
// groovy DSL
test {
jacoco {
enabled = true
destinationFile = file("$buildDir/jacoco/${name}.exec")
includes = []
excludes = []
excludeClassLoaders = []
includeNoLocationClasses = false
@th-deng
th-deng / build.gradle
Created Jan 23, 2020
Config JacocoTaskExtension
View build.gradle
// groovy DSL
test {
jacoco {
destinationFile = file("$buildDir/jacoco/jacoco.exec")
}
}
@th-deng
th-deng / build.gradle
Last active Jan 23, 2020
Config JaCoCo report and violation rules
View build.gradle
// groovy DSL
jacocoTestReport {
reports {
// 원하는 리포트를 켜고 끌 수 있습니다.
html.enabled true
xml.enabled false
csv.enabled false
// 각 리포트 타입 마다 리포트 저장 경로를 설정할 수 있습니다.
@th-deng
th-deng / build.gradle
Last active Jan 23, 2020
Apply JaCoCo plugin
View build.gradle
// groovy DSL
plugins {
id 'jacoco'
}
jacoco {
// JaCoCo 버전
toolVersion = '0.8.5'
You can’t perform that action at this time.