我正在尝试使用 Robotium 创建一个测试方法来检查 Android 应用程序是否在单击按钮后完成(在代码中,当用户点击时调用 finish()
它)。
public void test_onclickExit_finish() {
String buttonText = resources.getString(R.string.exit);
Button exitButton = solo.getButton(buttonText, true);
solo.clickOnView(exitButton);
// check here that the app has finished
// wait for the activity to finish?
assertTrue(solo.getCurrentActivity() == null);
}
但是这个测试失败了。我不知道如何指示测试等到 Activity 完成。此外,我不确定使用 getCurrentActivity()
是否是检查应用程序是否已完成的好方法。
如何检查应用程序/Activity 是否已完成?
谢谢。
最佳答案
如果这是您的主要 Activity ,请使用:
assertTrue(solo.getCurrentActivity().isFinishing());
关于android - 如何在 Robotium 中检查应用程序是否已完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15418229/