aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-06-11 12:54:15 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2015-06-11 12:54:15 +0200
commitb856d82ae2080dd5c35a8d71c069490a87b14d8f (patch)
treef3ab73455df8cb296778e5c10173fe14b565ddd8
parent7a5121894ee0ede4f20a6d029e4880c68cd643b7 (diff)
downloadopen-keychain-b856d82ae2080dd5c35a8d71c069490a87b14d8f.tar.gz
open-keychain-b856d82ae2080dd5c35a8d71c069490a87b14d8f.tar.bz2
open-keychain-b856d82ae2080dd5c35a8d71c069490a87b14d8f.zip
Jacoco support for local unit tests
-rw-r--r--OpenKeychain/build.gradle33
-rw-r--r--README.md8
2 files changed, 38 insertions, 3 deletions
diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle
index 081d87462..1334d0d66 100644
--- a/OpenKeychain/build.gradle
+++ b/OpenKeychain/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'witness'
+apply plugin: 'jacoco'
dependencies {
// NOTE: Always use fixed version codes not dynamic ones, e.g. 0.7.3 instead of 0.7.+, see README for more information
@@ -136,6 +137,10 @@ android {
// Reference them in .xml files.
resValue "string", "account_type", "org.sufficientlysecure.keychain.debug.account"
+
+ // Disabled: only works for androidTest not test!
+ // Enable code coverage (Jacoco)
+ //testCoverageEnabled true
}
}
@@ -187,7 +192,33 @@ android {
exclude 'LICENSE.txt'
}
}
-
+
+task jacocoTestReport(type:JacocoReport) {
+ group = "Reporting"
+ description = "Generate Jacoco coverage reports"
+
+ classDirectories = fileTree(
+ dir: "${buildDir}/intermediates/classes/debug",
+ excludes: ['**/R.class',
+ '**/R$*.class',
+ '**/*$ViewInjector*.*',
+ '**/BuildConfig.*',
+ '**/Manifest*.*']
+ )
+
+ sourceDirectories = files("${buildDir.parent}/src/main/java")
+ additionalSourceDirs = files([
+ "${buildDir}/generated/source/buildConfig/debug",
+ "${buildDir}/generated/source/r/debug"
+ ])
+ executionData = files("${buildDir}/jacoco/testDebug.exec")
+
+ reports {
+ xml.enabled = true
+ html.enabled = true
+ }
+}
+
// NOTE: This disables Lint!
tasks.whenTaskAdded { task ->
if (task.name.contains('lint')) {
diff --git a/README.md b/README.md
index ab8df9807..7520f06c2 100644
--- a/README.md
+++ b/README.md
@@ -51,8 +51,12 @@ Select everything for the newest SDK Platform, API 22, and also API 21
### Run Tests
1. Use OpenJDK instead of Oracle JDK
-2. Execute ``./gradlew clean``
-3. Execute ``./gradlew testDebug --continue``
+2. Execute ``./gradlew clean testDebug --continue``
+
+### Run Jacoco Test Coverage
+1. Use OpenJDK instead of Oracle JDK
+2. Execute ``./gradlew clean testDebug jacocoTestReport``
+3. Report is here: OpenKeychain/build/reports/jacoco/jacocoTestReport/html/index.html
### Development with Android Studio