Starting Instrumentation tests from an ABD shell
works fine:
adb shell am instrument de.manayv.lotto.test/android.support.test.runner.AndroidJUnitRunner
To execute theses tests on devices not connected to a computer, I try to execute these tests from an app (neither the target app nor the test app) using following code:
String packageName = "de.manayv.lotto.noonlinegambling";
final List<InstrumentationInfo> list = getPackageManager().queryInstrumentation(
packageName, 0);
if (list.isEmpty()) {
Toast.makeText(this, "Cannot find instrumentation for " + packageName,
Toast.LENGTH_SHORT).show();
return;
}
final InstrumentationInfo instrumentationInfo = list.get(0);
final ComponentName componentName = new ComponentName(instrumentationInfo.packageName,
instrumentationInfo.name);
if (!startInstrumentation(componentName, null, null)) {
Toast.makeText(this, "Cannot run instrumentation for " + packageName,
Toast.LENGTH_SHORT).show();
}
Debugging retrieves following correct values:
instrumentationInfo.packageName = de.manayv.lotto.test
instrumentationInfo.name = android.support.test.runner.AndroidJUnitRunner
Though startInstrumentation()
returns with true, the tests won't be executed. Any ideas?
I found the problem. It's the second null parameter in startInstrumentation(). I changed the code to:
To execute all tests contained in a (Java) package, use instead: