JaCoCo returning 0% Coverage with Kotlin and Android 3.0

You can get line-by-line coverage for both Java and Kotlin code by defining the two different directories for generated .class files: def debugTree = fileTree(dir: “${buildDir}/intermediates/classes/debug”, excludes: fileFilter) def kotlinDebugTree = fileTree(dir: “${buildDir}/tmp/kotlin-classes/debug”, excludes: fileFilter) Then, simply include both fileTrees in your classDirectories: classDirectories.from = files([debugTree], [kotlinDebugTree])

What is the branch in the destructor reported by gcov?

In a typical implementation the destructor usually has two branches: one for non-dynamic object destruction, another for dynamic object destruction. The selection of a specific branch is performed through a hidden boolean parameter passed to the destructor by the caller. It is usually passed through a register as either 0 or 1. I would guess … Read more

Perl build, unit testing, code coverage: A complete working example

It took me a while and it also took me taking small snippets from a number of different sources and melting them together, but I think I have a small working example that sufficiently demonstrates to a Perl newbie the Perl build process including unit testing and code coverage analysis & reporting. (I’m using ActiveState … 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

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

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