workaround for coverage bug (for now!)
see android bug report https://code.google.com/p/android/issues/detail?id=170607
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user