aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenKeychain/build.gradle7
-rw-r--r--OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java29
2 files changed, 34 insertions, 2 deletions
diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle
index f85678b67..491926a4e 100644
--- a/OpenKeychain/build.gradle
+++ b/OpenKeychain/build.gradle
@@ -114,7 +114,7 @@ android {
versionCode 32300
versionName "3.2.3"
applicationId "org.sufficientlysecure.keychain"
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "org.sufficientlysecure.keychain.JacocoWorkaroundJUnitRunner"
}
compileOptions {
@@ -217,7 +217,10 @@ task jacocoTestReport(type:JacocoReport) {
"${buildDir}/generated/source/buildConfig/debug",
"${buildDir}/generated/source/r/debug"
])
- executionData = files("${buildDir}/jacoco/testDebug.exec")
+ executionData = files([
+ "${buildDir}/jacoco/testDebug.exec",
+ "${buildDir}/outputs/code-coverage/connected/coverage.ec"
+ ])
reports {
xml.enabled = true
diff --git a/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java
new file mode 100644
index 000000000..b310ed5b8
--- /dev/null
+++ b/OpenKeychain/src/androidTest/java/org/sufficientlysecure/keychain/JacocoWorkaroundJUnitRunner.java
@@ -0,0 +1,29 @@
+package org.sufficientlysecure.keychain;
+
+
+import java.lang.reflect.Method;
+
+import android.os.Bundle;
+import android.support.test.runner.AndroidJUnitRunner;
+
+
+public class JacocoWorkaroundJUnitRunner extends AndroidJUnitRunner {
+ static {
+ System.setProperty("jacoco-agent.destfile", "/data/data/"
+ + BuildConfig.APPLICATION_ID + "/coverage.ec");
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ try {
+ Class rt = Class.forName("org.jacoco.agent.rt.RT");
+ Method getAgent = rt.getMethod("getAgent");
+ Method dump = getAgent.getReturnType().getMethod("dump", boolean.class);
+ Object agent = getAgent.invoke(null);
+ dump.invoke(agent, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ super.finish(resultCode, results);
+ }
+} \ No newline at end of file