我想使用 JUnit 为我的 android 应用程序编写测试用例。 我遇到了一些问题。
是否可以检查 Activity 当前是否显示了一些对话框? 这是我的测试应用程序的一小部分:
...
Instrumentation instr = getInstrumentation();
monitor = instr.addMonitor(MainActivity.class.getName(), null, false);
/* Click on login button */
TouchUtils.clickView(this, mLoginButton);
/* wait MainActivity */
mMainActivity = instr.waitForMonitorWithTimeout(monitor, 3);
assertNotNull(mMainActivity);
/* Here a want to check that progress dialog displayed on mMainActivity */
提前致谢!
最佳答案
看看 Robotium
“一个开源测试框架,旨在使 Android 应用程序的自动黑盒测试比开箱即用的 Android 仪器测试更快、更容易。”
首页:
http://www.robotium.org/
资源:
http://github.com/jayway/robotium
请注意,Robotium 项目由我工作的公司维护
关于android - 如何在android单元测试期间检查 Activity 是否显示对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3778256/