0
我想用測試應用程序中的Instrumentation接口來測試我的應用程序。 我有一個自定義活動,我的每一個活動延伸。在此我要開始的儀器來獲得程序的信息:儀器Android應用程序與啓動儀器
public class BxActivity extends Activity {
@Override
protected void onResume() {
super.onResume();
...
boolean instru = startInstrumentation(new ComponentName(BxActivity.this, InstrumentationRobot.class), null, null);
恕我直言,這應該重新啓動與在InstrumentationRobot.class儀器代碼的應用程序。它在同一個Android項目和包中。
public class InstrumentationRobot extends Instrumentation {
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
Log.v("InstrRobot", "Hello from Robot");
start();
}
我已經添加了儀器的清單如下:
<instrumentation
android:name="InstrumentationRobot" (class in the same pkg)
android:targetPackage="my.package.name" />
</application>
這是我的儀表正確的清單代碼,所以我的小機器人打印出「你好」給我。
謝謝,soeren