Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacaco implementation for understanding coverage via e2e tests #261

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'maven-publish'
id("io.freefair.aspectj.post-compile-weaving") version "8.0.1"
id "jacoco"
}

jacoco {
toolVersion = "0.8.8"
// If need to create the reports only in this directory - rather than on report folder in build.gradle
// reportsDirectory = layout.buildDirectory.dir('jacoco')
}

group = 'com.github.znsio'
Expand Down Expand Up @@ -173,6 +180,20 @@ tasks.register('run', JavaExec) {
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
}

// This code is created to trigger the jacoco test on the basis of run tag - currently it executes only on test and build
//task jacocoRun(type: JacocoReport, dependsOn: ['run']) {
// // Set the appropriate source directories for your project
// sourceDirectories.from = files('src/test/java')
// classDirectories.from = files('build/classes/java/test')
// executionData.from = fileTree(dir: 'build/jacoco', includes: ['*.exec'])
// reports {
// // html.enabled = true
// html.required = true
// // xml.enabled = true
// xml.required = true
// }
//}

test {
useJUnitPlatform()

Expand All @@ -199,6 +220,45 @@ test {
html.outputLocation.set(file("$buildDir/unit-test-results"))
junitXml.outputLocation.set(file("$buildDir/unit-test-results"))
}

// Here we are manually updating the report portal as true
// jacoco {
// enabled = true
// }

finalizedBy jacocoTestReport
}

// Defined jacoco in this manner as well
//jacoco {
// toolVersion = "0.8.8"
// applyTo run
// reportsDirectory = layout.buildDirectory.dir('jacoco')
//}



//jacocoTestReport {
// dependsOn test // tests are required to run before generating the report
//}
//
//
//jacocoTestReport {
// dependsOn run // tests are required to run before generating the report
// reports {
// xml.required = false
// csv.required = false
// html.outputLocation = layout.buildDirectory.dir('jacoco')
// }
//}
//
//
//tasks.register('applicationCodeCoverageReport', JacocoReport) {
// executionData run
// sourceSets sourceSets.main


// It is just indirectly calling jacoco - so it get trigger on hitting ./gradlew run
// jacocoTestReport.dependsOn jacocoRun

shadowJar.finalizedBy sourcesJar