从ABD shell
正常工作开始仪器测试:
adb shell am instrument de.manayv.lotto.test/android.support.test.runner.AndroidJUnitRunner
为了在未连接到计算机的设备上执行这些测试,我尝试使用以下代码从应用程序(既不是目标应用程序也不是测试应用程序)执行这些测试:
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();
}
调试检索以下正确值:
instrumentationInfo.packageName = de.manayv.lotto.test
instrumentationInfo.name = android.support.test.runner.AndroidJUnitRunner
虽然startInstrumentation()
返回 true,但不会执行测试。有任何想法吗?