Jacoco is not detecting coverage for static method

456 views
Skip to first unread message

Sidhartha Das

unread,
Aug 16, 2023, 7:10:39 AM8/16/23
to JaCoCo and EclEmma Users
Hi,

I am trying to execute Jacoco report. I have some static method which I have written test cases using Mock static. In local It shows Junit coverage. But In Jacoco report I dnt see the coverage for static methods. Can you please suggest.
 Below the build.gradle

plugins {
id 'org.springframework.boot' version '2.3.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'jacoco'   //jacoco plugin
}

group = 'com.stackfortech'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
finalizedBy jacocoTestReport  //run right after ./gradlew clean build
}
jacocoTestReport{                 //configuration for report formats.
dependsOn test
reports {
xml.enabled true
csv.enabled true
html.enabled true
}
finalizedBy jacocoTestCoverageVerification  //run right after jacocoTestReport
}
jacocoTestCoverageVerification {   //Verifies the code coverage rule if enabled.
violationRules {
rule {
enabled = true
limit {
minimum = 0.25
}
}
}
}

Marc Hoffmann

unread,
Aug 16, 2023, 8:22:55 AM8/16/23
to JaCoCo and EclEmma Users
Hi,

in general mocking (when it involves class files transformation) does not play well with JaCoCo.

What exactly is your “local” tooling which works?

Regards,
-marc



--
You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/33f46448-c580-4357-a08f-563139b89449n%40googlegroups.com.

Sidhartha Das

unread,
Aug 16, 2023, 9:22:47 AM8/16/23
to JaCoCo and EclEmma Users

Local means when I run as Junit in the STS IDE.
Reply all
Reply to author
Forward
0 new messages