Last active
August 29, 2015 14:25
-
-
Save quentin7b/bad81fc4075d9320941c to your computer and use it in GitHub Desktop.
[Robolectric / Jacoco] Test module build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'jacoco' | |
android { | |
testOptions { | |
unitTests.returnDefaultValues = true | |
} | |
jacoco { | |
version "0.7.1.201405082137" | |
} | |
} | |
jacoco { | |
toolVersion "0.7.1.201405082137" | |
} | |
// Define coverage source. | |
def coverageSourceDirs = [ | |
'src/main/java' | |
] | |
// Define jacoco task (code coverage) | |
// Be aware of the flavors/config you are using, here it is Debug, see debug every time in pathes. | |
task jacocoTestReport(type: JacocoReport, dependsOn: "testDebug") { | |
group = "Reporting" | |
description = "Generate Jacoco coverage reports after running tests." | |
reports { | |
xml.enabled = true | |
html.enabled = true | |
} | |
// class R is used, but usage will not be covered, so ignore this class from report | |
// See the debug in the path | |
classDirectories = fileTree( | |
dir: './build/intermediates/classes/debug', | |
excludes: [ | |
'**/R*.class' | |
] | |
) | |
sourceDirectories = files(coverageSourceDirs) | |
// See the debug | |
executionData = files('./build/jacoco/testDebug.exec') | |
} | |
dependencies { | |
// Using robolectric | |
testCompile 'org.robolectric:robolectric:3.0-rc3' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment