Robotiumã§Androidã¢ããªã®ã·ããªãªãã¹ããèªååãã
Androidã¢ããªã®ãã¹ãèªååã«ã¤ãã¦è²ã 調æ»ãã¦ããããRobotiumã¨ãããã¹ããã¼ã«ãè¦ã¤ãã¾ããããã®ãã¼ã«ã便å©ãªãã§ãããå½å ã§ã¯ã¾ã ãã¾ãç¥ããã¦ãªãã¿ãããªã®ã§ç´¹ä»ãã¦ã¿ã¾ãã
Robotiumã¨ã¯
Robotiumã¨ã¯Androidã¢ããªã±ã¼ã·ã§ã³ã®ãã©ãã¯ããã¯ã¹ã¬ãã«ã®ãã¹ããèªååããããã®Test Frameworkã§ãã
AndroidçSeleniumã¨ããã®ã謳ãæå¥ã®ããã§ãã
Android SDKãæä¾ãã¦ããActivityInstrumentationTestCase2ã§ã¯è¤æ°ã®Activityã«ã¾ããããããªãã¹ããé£ãããã¨ã§ç¥ããã¦ãã¾ãããRobotiumã¯Activityãã¾ããããã¹ããç°¡åã«èªååãããã¨ãã§ãã¾ããã¾ããã¦ã¼ã¶ã¼æä½ãã¨ãã¥ã¬ã¼ãããé¢æ°ãè±å¯ã«ç¨æããã¦ãã¦ãå¾æ¥ã¯è¤éã«ãªããã¡ã ã£ããã¹ãã³ã¼ããç°¡åã«è¨è¿°ãããã¨ãã§ãã¾ãã
以ä¸ãRobotiumãå©ç¨ãããã¹ãã³ã¼ãã®ä¾ã§ãã
public void testAddNote() throws Exception { //ã¡ãã¥ã¼ãã¿ã³ãã"Add note"ãé¸æ solo.clickOnMenuItem("Add note"); //NoteEditorã¢ã¯ãã£ããã£ãèµ·åãã¦ãããã¨ãç¢ºèª solo.assertCurrentActivity("Expected NoteEditor activity", "NoteEditor"); //0çªç®ã®ããã¹ããã£ã¼ã«ãã«"Note 1"ã¨å ¥åãã solo.enterText(0, "Note 1"); //"NotesList"ã¢ã¯ãã£ããã£ã«æ»ã solo.goBackToActivity("NotesList"); //ç¾å¨ã®ç»é¢ä¸ã«ãã"Note 1"ã¨ããããã¹ããæ¢ã boolean actual = solo.searchText("Note 1"); //ããã¹ããåå¨ããã°ãã¹ãOK assertEquals("Note 1 is not found", expected, actual); }
ãã®ãããªå½¢ã§ã¦ã¼ã¶ã¼ã®æä½ããã¨ã«ãç´æçã«ãã¹ãã³ã¼ããæ¸ããã¨ãã§ãã¾ãã
ãã£ãã試ãã¦ã¿ã
1. ãµã³ãã«ããã¸ã§ã¯ãã®ãã¦ã³ãã¼ã
RobotiumのサイトããExampleTestProject_v8.zip (2010/10/19ç¾å¨ã®ææ°ï¼ãè½ã¨ãã¾ãããã®ã¾ã¾Eclipseã§ããã¸ã§ã¯ããã¤ã³ãã¼ããã¾ãã
2. NotePadããã¸ã§ã¯ãã®ä½æ
ExampleTestProject ã¯AndroidSDKã«ä»å±ãããNotePadããã¸ã§ã¯ãã®ãã¹ãããã°ã©ã ã¨ãã¦åä½ãããããNotePadã®ã½ã¼ã¹ã³ã¼ãããEclipseã®æ°è¦ããã¸ã§ã¯ãä½æããã¤ã³ãã¼ããã¾ãã
ï¼ææ°ã®SDKã§ãã¨ãandroid-sdk-mac_86/samples/android-7/NotePad/ ã«åå¨ããããã§ããï¼
ææ³
ã¦ã¼ã¶ã¼æä½ã«é¢ãããã¹ãã³ã¼ããããªãã®é¨åã©ãããã¦ãããã®ã§ããã®ç¹ä½¿ãåæã¯é常ã«è¯ãã¨æãã¾ããListã®xxåç®ãã¯ãªãã¯âã¡ãã¥ã¼ãã¿ã³ã®xxxxãã¯ãªãã¯âxxxxxã®ããã¹ãã表示ããã¦ããã確èªãã¨ãã£ããããªãã¹ãã±ã¼ã¹ãã»ã¼ä¸ç¬ã§æ¸ããã¨ãã§ãã¾ãã
ããã¯ãªã®ã¯ä¿¡é ¼æ§ã§ãå é¨ã®å®è£ ãè¦ãã¨ãªãã¬ã¯ã·ã§ã³ã使ã£ã¦WindowManagerãããã¥ã¼ãåå¾ãããã¨ãããªãã¨ã°ããã¨ããã£ã¦ããã®ã§ãå°æ¥çã«OSããã¼ã¸ã§ã³ã¢ããããããã£ãã¨ãã®åä½ããæ©ç¨®å¥ã®åä½ã¯ä¸å®ãæ®ãã¾ããã¾ãææ°ã®ãã¼ã¸ã§ã³ã§ããåã試ããéãã§ã¯ Solo.goBack() ãåä½ããªãã£ããããSolo.goBackToActivity("NotesList") ã«æ¸ãç´ããããã¾ããã
ã¨ããããã§ãã¾ã ä¿¡é ¼æ§ã«ä¸å®ãããã®ã§ãRobotiumã ãã§ãã¹ããæ¸ãã¨ããããã«ã¯ãããªãã¨ã®ãåã®ææ³ã§ããèªåãã¹ãã®ã¡ã¤ã³ã¯AndroidSDKæ¨æºã®ãã¹ããã¬ã¼ã ã¯ã¼ã¯ã§ä½ã£ãåä½ãã¹ãã§è¡ãããµãçã«ä¸»è¦ãªã·ããªãªãã¹ããRobotiumã§ä½æãããã¨ããã®ã¯ã¢ãªãã¨æãã¾ãã