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

Android test code coverage with JaCoCo Gradle plugin

Here is how I’m using Jacoco: buildscript { repositories { mavenLocal() mavenCentral() } dependencies { classpath ‘com.android.tools.build:gradle:0.12.+’ classpath ‘org.robolectric:robolectric-gradle-plugin:0.11.+’ } } apply plugin: ‘com.android.application’ apply plugin: ‘robolectric’ apply plugin: ‘jacoco’ android { compileSdkVersion 20 buildToolsVersion “20.0.0” defaultConfig { applicationId “YOUR_PACKAGE_NAME” minSdkVersion 10 targetSdkVersion 20 testHandleProfiling true testFunctionalTest true } buildTypes { debug { testCoverageEnabled false … Read more

Detailed guide on using gcov with CMake/CDash?

I’ve been using https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake successfully. Just followed the guidelines: added the files to my CMAKE_MODULE_PATH directory, added set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) if(CMAKE_COMPILER_IS_GNUCXX) include(CodeCoverage) setup_target_for_coverage(${PROJECT_NAME}_coverage ${PROJECT_TEST_NAME} coverage) endif() in my CMakeLists.txt. I also added manually gcov as a dependency for my target: if(CMAKE_COMPILER_IS_GNUCXX) target_link_libraries(${PROJECT_TEST_NAME} gcov) endif() With this, I just type make my_project_coverage and I get the html … Read more

Exclude methods from code coverage with Cobertura

You can exclude classes from instrumentation. Then they should not appear on reports. See exclude statements below. You can also ignore calls to some methods. See ignore statement below. If you are using maven, see maven plugin manual. <configuration> <instrumentation> <ignores> <ignore>com.example.boringcode.*</ignore> </ignores> <excludes> <exclude>com/example/dullcode/**/*.class</exclude> <exclude>com/example/**/*Test.class</exclude> </excludes> </instrumentation> </configuration> And for ant see this. <cobertura-instrument … Read more