android - 如何在android单元测试期间检查 Activity 是否显示对话框

标签 android unit-testing testing junit

我想使用 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/

相关文章:

机器人 Espresso :test for new activity launch on button click is failing

java - IntelliJ 2017 中没有代码覆盖率

unit-testing - Resharper 从不同位置运行 UnitTest

unit-testing - 使用 TFS 进行自动化测试 - 在所有已注册代理上全面运行测试

testing - 持续集成服务器上的集成测试

perl - 在测试独立的 Perl 脚本时覆盖变量

android - 使用 Android 检测人的跌倒

java - 并行动画 View

android - 如何在 bluestacks 模拟器中将屏幕尺寸设置为 4'7 in?

unit-testing - 我如何在 play framework 2 scala 中对 Controller 进行单元测试