有人使用 Robotium 或 Calculon 来测试 Android 应用程序吗?

发布于 2024-08-22 09:50:13 字数 66 浏览 4 评论 0原文

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

Has anyone used Robotium or Calculon for testing Android apps? Are they useful? Any recommendations on which is better?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2024-08-29 09:50:13

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

嗯,目前它只是我从另一个项目中提取的一堆源文件...请注意,这个库仍然是一个非常
早期原型。它的 API 可能会
改变。 来源

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

  • clickOnButton、clickOnText
  • EnterText
  • getCurrentButtons、getCurrentEditTexts、getCurrentImageViews、getCurrentSpinners、getCurrentTextViews
  • pressMenuItem、pressSpinnerItem
  • searchText、searchEditText、searchButton

以下是《入门指南》中的代码示例:

  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 类,请尝试一下。请查看入门指南以获取说明。

I'd go with Robotium since Calculon is still in very early stages. Here's a comment from Calculon's author:

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

I've played with Robotium today, it definitely makes writing functional tests fun. To give you an idea, here are a few method highlights from the API:

  • clickOnButton, clickOnText
  • enterText
  • getCurrentButtons, getCurrentEditTexts, getCurrentImageViews, getCurrentSpinners, getCurrentTextViews
  • pressMenuItem, pressSpinnerItem
  • searchText, searchEditText, searchButton

Here is a code sample from the Getting Started Guide:

  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"));}

Definitely give it a try if you're going to write ActivityInstrumentationTestCase2 classes. Check out the Getting Started guide for instructions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文