android - 有没有人使用 Robotium 或 Calculon 来测试 Android 应用程序?

标签 android unit-testing testing acceptance-testing

有没有人使用 Robotium 或 Calculon 来测试 Android 应用程序?它们有用吗?有什么更好的建议吗?

最佳答案

我会选择 Robotium,因为 Calculon 仍处于早期阶段。这是 Calculon 作者的评论:

Well, currently it’s just a bunch of source files which I pulled out of another project...Note that this library is still a very early prototype. Its API will probably change. Source

我今天玩过 Robotium,它确实让编写功能测试变得有趣。为了给您一个想法,以下是 API 中的一些方法亮点:

  • 点击按钮,点击文本
  • 输入文本
  • getCurrentButtons、getCurrentEditTexts、getCurrentImageViews、getCurrentSpinners、getCurrentTextViews
  • 按下菜单项,按下微调器项
  • 搜索文本、搜索编辑文本、搜索按钮

这是入门指南中的代码示例:

  public void testTextIsSaved() throws Exception {
    solo.clickOnText("Other");
    solo.clickOnButton("Edit");
    assertTrue(solo.searchText("Edit Window"));
    solo.enterText(1, "Some text for testing purposes")
    solo.clickOnButton("Save");
    assertTrue(solo.searchText("Changes have been made successfully"));
    solo.clickOnButton("Ok");
    assertTrue(solo.searchText("Some text for testing purposes"));}

如果您要编写 ActivityInstrumentationTestCase2 类,一定要试一试。查看Getting Started指导说明。

关于android - 有没有人使用 Robotium 或 Calculon 来测试 Android 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2300122/

相关文章:

testing - 无法在集成测试中访问 Sails.js 应用程序实例

javascript - 使用nodejs测试js文件

ruby-on-rails - 测试函数包含 API 请求

python - Python 单元测试套件

android - 无法在 app/build.gradle 中在线导入 com.android.build.OutputFile 时解析符号 'build'

android - 创建比例 View 的最有效方法

android - 如何将 inflatedView 添加到线性布局

java - XmlUnit:引用了实体 "nbsp",但未声明

unit-testing - Visual Studio 2012 测试项目混合模式运行时

android - 使用 START_STICKY 启动服务进程后的 onStartCommand