简体   繁体   中英

Is it possible to create an android test “apk” running outside the target apk?

Is it possible to create an android test "apk" outside the target apk? Now what I know is need to test code(apk) within target apk.

Already solved. Remember to run the test with cmd. Here is the code snippet:

Runtime runtime = new Runtime();
String testPackage = "com.android.contacts.test";
String testRunner = "com.android.contacts.test.G11NInstrumentationTestRunner";
String command = "am instrument --user 0 -w " + testPackage + "/" + testRunner;
runtime.exec(command);

The testRunner is my customized InstrumentationTestRunner, you can simply use android.test.InstrumentationTestRunner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM