开发者

Has anyone used Robotium or Calculon for testing Android apps?

Has anyone used Robotium or Calculon for testing Android apps? Are they useful? Any recommendations on which is bett开发者_开发百科er?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜