Skip to content

Commit

Permalink
test: add jacoco
Browse files Browse the repository at this point in the history
  • Loading branch information
ReaJason committed Nov 24, 2024
1 parent d37b0a1 commit a42b2bd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Test with Gradle
run: ./gradlew test
run: ./gradlew test
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: generator/build/reports/jacoco/test/jacocoTestReport.csv
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
allprojects {
apply(plugin: 'java')
apply(plugin: 'jacoco')

repositories {
mavenCentral()
Expand All @@ -11,6 +12,13 @@ allprojects {
}
}

test {
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
}

dependencies {
testImplementation platform('org.junit:junit-bom:5.11.3')
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
16 changes: 16 additions & 0 deletions generator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ plugins {
group = 'com.reajason.javaweb.memsell'
version = '1.0-SNAPSHOT'

jacocoTestReport {
reports {
html.required = true
csv.required = true
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'com/reajason/javaweb/memsell/**/godzilla/**',
'com/reajason/javaweb/memsell/**/injector/**',
'com/reajason/javaweb/config/**'
])
}))
}
}

dependencies {
implementation 'net.bytebuddy:byte-buddy:1.15.1'
implementation 'javax.servlet:javax.servlet-api:3.0.1'
Expand Down

0 comments on commit a42b2bd

Please sign in to comment.