Skip to content

Commit

Permalink
Adds task to generate jacocoTestReport
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhitagarwal1612 committed Feb 20, 2018
1 parent b1c9cc5 commit 2042842
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.trickyandroid:jacoco-everywhere:0.2.1'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'org.jacoco:org.jacoco.core:0.7.9'
}
configurations.all {
resolutionStrategy {
Expand Down
16 changes: 14 additions & 2 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ android {
signingConfig signingConfigs.release
}
minifyEnabled(true)
testCoverageEnabled(true)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
resValue("bool", "FIREBASE_CRASH_ENABLED", "false")
}
Expand All @@ -105,12 +106,12 @@ android {
signingConfig signingConfigs.release
}
minifyEnabled(true)
testCoverageEnabled(true)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
resValue("bool", "FIREBASE_CRASH_ENABLED", "true")
}
debug {
debuggable(true)
// Allows AndroidTest JaCoCo reports to be generated
testCoverageEnabled(true)
resValue("bool", "FIREBASE_CRASH_ENABLED", "false")
}
Expand Down Expand Up @@ -151,7 +152,18 @@ android {
javaMaxHeapSize '2048M'
}

testOptions.unitTests.includeAndroidResources true
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true

all {
jacoco {
includeNoLocationClasses = true
}
}
}
}
}

configurations.all {
Expand Down
47 changes: 47 additions & 0 deletions config/quality.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
apply plugin: 'jacoco'

/*
* Copyright 2015 Vincent Brison.
Expand Down Expand Up @@ -91,4 +92,50 @@ android {
htmlOutput file("$reportsDir/lint/lint-result.html")
xmlOutput file("$reportsDir/lint/lint-result.xml")
}
}

def coverageSourceDirs = [
'src/main/java',
'src/debug/java'
]


task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
group = 'Reporting'
description = 'Generate JaCoCo coverage reports'

reports {
xml.enabled = true
html.enabled = true
}

classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: [
'**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/Dagger*.*',
'**/*Module_Provide*Factory.*',
'**/*_Factory.*',
'**/*_MembersInjector.*',
]
)

sourceDirectories = files(coverageSourceDirs)
executionData = fileTree(
dir: "$buildDir",
include: ['jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec']
)

doFirst {
files('build/intermediates/classes/debug').getFiles().each { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}

0 comments on commit 2042842

Please sign in to comment.