Testng, Emma, Cobertura, coverage and JDK 7 result in ClassFormatError and VerifyError

I had same problem using maven cobertura plugin. All tests failed when run from cobertura:report. But all tests succeeded when run directly from surefire plugin. As some of you already said the problem is that coberture byte code instrumentation of is not compatible with JDK7. You can see here http://vikashazrati.wordpress.com/2011/10/09/quicktip-verifyerror-with-jdk-7/ that the exception is related … Read more

JaCoCo: exclude generated methods (using it with Lombok)

Also another way to exclude lombok generated classes since jacoco 0.8.0 and lombok 1.16.14. Luckily, beginning with version 0.8.0, Jacoco can detect, identify and ignore Lombok-generated code. The only thing you as the developer have to do is to create a file named lombok.config in your directory’s root and set the following flag: lombok.addLombokGeneratedAnnotation = … Read more

8 branches for try with resources – jacoco coverage possible?

Well I can’t tell you what the exact problem with Jacoco is, but I can show you how Try With Resources is compiled. Basically, there are a lot of compiler generated switches to handle exceptions thrown at various points. If we take the following code and compile it public static void main(String[] args){ String a … Read more

How would I add an annotation to exclude a method from a jacoco code coverage report?

Since there are no direct answers to this, did a bit of research and came across this PR. https://github.com/jacoco/jacoco/pull/822/files private static boolean matches(final String annotation) { final String name = annotation .substring(Math.max(annotation.lastIndexOf(“https://stackoverflow.com/”), annotation.lastIndexOf(‘$’)) + 1); return name.contains(“Generated”) } You can create any annotation with name containing “Generated”. I’ve created the following in my codebase to … Read more

SonarQube not picking up Unit Test Coverage

You were missing a few important sonar properties, Here is a sample from one of my builds: sonar.jdbc.dialect=mssql sonar.projectKey=projectname sonar.projectName=Project Name sonar.projectVersion=1.0 sonar.sources=src sonar.language=java sonar.binaries=build/classes sonar.tests=junit sonar.dynamicAnalysis=reuseReports sonar.junit.reportsPath=build/test-reports sonar.java.coveragePlugin=jacoco sonar.jacoco.reportPath=build/test-reports/jacoco.exec The error in Jenkins console output can be pretty useful for getting code coverage to work. Project coverage is set to 0% since there is … Read more

Cannot use jacoco JVM args and surefire JVM args together in maven

Try using @{argLine} instead of ${argLine} (or surefire.argLine in your case) It allows surefire to read a property as modified by other plugins instead of reading the one substituted by Maven itself. Then you can set the argLine param to empty in Maven properties: <properties> <argLine></argLine> </properties> Which now will not cause any problems. More … Read more

JaCoCo SonarQube incompatible version 1007

As already mentioned, this is due to a break in JaCoCo maven plugin code. You can (temporarily) specify the version in your jenkins maven command like: clean org.jacoco:jacoco-maven-plugin:<version>:prepare-agent install e.g. clean org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent install This was the workaround that helped us. But like most people, I’m still waiting for the fix to come.

Maven Jacoco Configuration – Exclude classes/packages from report not working

Your XML is slightly wrong, you need to add any class exclusions within an excludes parent field, so your above configuration should look like the following as per the Jacoco docs <configuration> <excludes> <exclude>**/*Config.*</exclude> <exclude>**/*Dev.*</exclude> </excludes> </configuration> The values of the exclude fields should be class paths (not package names) of the compiled classes relative … Read more

How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?

I was in the same situation as you, the half answers scattered throughout the Internet were quite annoying, since it seemed that many people had the same issue, but no one could be bothered to fully explain how they solved it. The Sonar docs refer to a GitHub project with examples that are helpful. What … Read more