I made my test-runner inherit from InstrumentationTestRunner and took the extra data in onCreate():
public class DepponTestRunner extends InstrumentationTestRunner {
public static String BAR;
public void onCreate(Bundle arguments) {
if (null != arguments) {
BAR = (String) arguments.get("foo"));
}
super.onCreate(arguments);
}
}
I added to Android.mk:
LOCAL_JAVA_LIBRARIES := android.test.runner
And to AndroidManifest.xml:
<instrumentation
android:name="com.example.MyTestRunner"
android:targetPackage="com.example" />
Ran it using this command line:
adb shell am instrument -e class test类全名\#方法名 -e foo june123456789asdfghjklqwertyuiopzxcvbnm -e bert june123 -w com.deppon.app.june.test/deppon.util.DepponTestRunner
public class DepponTestRunner extends InstrumentationTestRunner {
public static String BAR;
public void onCreate(Bundle arguments) {
if (null != arguments) {
BAR = (String) arguments.get("foo"));
}
super.onCreate(arguments);
}
}
I added to Android.mk:
LOCAL_JAVA_LIBRARIES := android.test.runner
And to AndroidManifest.xml:
<instrumentation
android:name="com.example.MyTestRunner"
android:targetPackage="com.example" />
Ran it using this command line:
adb shell am instrument -e class test类全名\#方法名 -e foo june123456789asdfghjklqwertyuiopzxcvbnm -e bert june123 -w com.deppon.app.june.test/deppon.util.DepponTestRunner