Feature Request for GoogleInstrumentationTestRunner:
The GoogleInstrumentationTestRunner needs to provide access to
AndroidTestRunner in order to be able to add TestListeners. When extending from
the GoogleInstrumentationTestRunner, a custom TestRunner has no way of adding
own listeners to the AndroidTestRunner.
The only way I was able to do it as a workaround was to use reflection in my
custom TestRunner:
@Override
public void start() {
mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
try {
Class<?> c = getClass();
Field bridgeTestRunner = c.getSuperclass().getDeclaredField("bridgeTestRunner");
bridgeTestRunner.setAccessible(true);
Object obj = bridgeTestRunner.get(this);
Method m = obj.getClass().getDeclaredMethod("getAndroidTestRunner", null);
AndroidTestRunner androidTestRunner = (AndroidTestRunner)m.invoke(obj);
androidTestRunner.addTestListener(mListener);
} catch (NoSuchFieldException x) {
Log.e(LOG_TAG, x.toString());
} catch (SecurityException e) {
Log.e(LOG_TAG, e.toString());
} catch (NoSuchMethodException e) {
Log.e(LOG_TAG, e.toString());
} catch (IllegalAccessException x) {
Log.e(LOG_TAG, x.toString());
} catch (InvocationTargetException e) {
Log.e(LOG_TAG, e.toString());
}
super.start();
}
Please see thread in discussion group:
https://groups.google.com/forum/#!topic/android-test-kit-discuss/_Lu3odqITj0
Original issue reported on code.google.com by mario.bo...@gmail.com on 12 Nov 2013 at 9:59
Original issue reported on code.google.com by
mario.bo...@gmail.com
on 12 Nov 2013 at 9:59