ãè¶ è¨³ãAndroidã®UIãUnitTestã§ããNative Driver
Introducing Native Driverã®è¶ 訳ã
Native Driverã¯Web Driver APIã®å®è£ ã§ãWebã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãªããã¤ãã£ãã¢ããªã±ã¼ã·ã§ã³ã®UIãå©ããã®ãAndroidçããã¦ã³ãã¼ãåºæ¥ãããã«ãªã£ãã®ã§ãã¦ã¼ã¶ã¨ã³ã³ããªãã¥ã¼ã¿ããã£ããåéãGoogle Code (http://nativedriver.googlecode.com/ )ã«ç½®ãã¦ãããiPhone(iOS)çãéçºä¸ã§ãããã使ããã
WebDriverã¯ãã©ã¦ã¶ã®æ©è½ã綺éºã§ãªãã¸ã§ã¯ãæåãªAPIã¨ãã¦è¦ãã¦ãããã®ã§ãGoogleã§ã¯å¤ãã®ãã©ãããã©ã¼ã ä¸ã§Webã¢ããªã±ã¼ã·ã§ã³ããã¹ãããã®ã«WebDriverã使ã£ã¦ãããï¼WebDriverã«ã¤ãã¦ã¯ãこのブログ記事ãåç §ï¼
ãªãWebDriver APIããã¤ãã£ãã¢ããªã±ã¼ã·ã§ã³ã«ä½¿ãã®ãä¸æè°ã«æããããããªããçç±ã¨ãã¦ã¯ã
- ãã¤ãã£ãã¢ããªã±ã¼ã·ã§ã³ãWebã¢ããªã±ã¼ã·ã§ã³ããã¦ã¼ã¶ã¨ã®ããåãã¯åºæ¬åã:
- ã¯ãªãã¯ããã¼å ¥åãã¦ã£ã³ãã¦åãæ¿ããããã¹ããèªãã
- ãã¹ãã®è¨è¿°è ã¯ãµãã¼ããããããããã®ãã©ãããã©ã¼ã ãã¨ã«åããã¹ããæ¸ããªããã°ãããªãã
- ã¾ãå¥ã®APIã誰ãå¦ç¿ãããã¯ãªãã
- WebDriverã¯ãã§ã«ã¦ã¼ã¶å±¤ããããã¼ã«ã®ã¨ã³ã·ã¹ãã ããããWebDriverã«ä¼¼ãAPIãªãç°¡åã«çµ±åã§ããã
- ã¤ã¾ã: ãæ°ã«å ¥ãã®UIãã¹ãAPIãåå©ç¨ãããã
NativeDriverã¯ãWebDriverã®ãã£ããããã¨ããã¨æåãã¦ããã¨ããããã¤ãã£ãã¢ããªã±ã¼ã·ã§ã³ã«ãæã£ã¦ãããã¨ãã試ã¿ãWebDriver APIãããã¤ãã®ãã¼ã¨ãªãæã§æ¡å¼µããã¦ããã¤ãã£ãã¢ããªã±ã¼ã·ã§ã³ç¨ã«æ¢åã®APIãå翻訳ãã¦ããã
Androidç¨ã®Google Mapsã¢ããªã±ã¼ã·ã§ã³ã«å¯¾ããNativeDriverã®ãã¹ãã®ã³ã¼ãã¯ãããªæãã«ãªãã(ãã¹ã風æ¯ã¯動画ãè¦ããã)
AndroidNativeDriver driver = new AndroidNativeDriverBuilder() .withDefaultServer() .build(); driver.startActivity("com.google.android.maps.MapsActivity"); // placesãã¿ã³ãã¯ãªãã¯ãã¦Placesã¢ã¯ãã£ããã£ãéã // (æ¤ç´¢ããã¯ã¹ã®å³) AndroidNativeDriver btn = driver.findElement(By.id("btn_header_places")); btn.click(); // Placesã¦ã£ã³ãã¦ãéãã // Androidã®æ»ããã¿ã³ãæ¼ãã®ã¨ç価 driver.navigate().back(); // 横ç»é¢ã表示ããããã«å転ãã driver.rotate(ScreenOrientation.LANDSCAPE);
startActivityã¡ã½ããã¨ãã©ã¤ãã¼ãä½ããªãã¸ã§ã¯ããã«ãã¼ã®ä½¿ãæ¹ä»¥å¤ããã¹ã¦ã®APIå¼ã³åºãã¯ãæ¨æºã®WebDriver APIå¼ã³åºãã§åºæ¥ã¦ãããAndroid Debug Bridge(ADB)æ¥ç¶ã¨ä¸ç·ã«ãã©ã¤ãã¼ãæºåããã®ã§ããã«ãã¼ã§ãã©ã¤ãã¼ãä½ãå¿
è¦ãããã
Androidã®NativeDriverã¯Instrumentationã使ã£ã¦ãã¹ã対象ã®ã¢ããªã±ã¼ã·ã§ã³ãç£è¦ãæä½ãããInstrumentationã¯Androidã®æ¨æºæ©è½ã ããããã¤ãå¶éããããä¾ãã°ãå¥ããã»ã¹ã®ä¸é¨ã§ããUIãå©ããªãï¼ãããããªãã¨ãåºæ¥ãããæªæã®ããã¢ããªã±ã¼ã·ã§ã³ã端æ«ãä¹ã£åãã¦ãã¾ãï¼ãADBã解決ãã¦ãããã®ã¯ã¾ãã«ãããADBã¯å¤é¨ããã®æ¥ç¶ã§ãç¹å®ã®ã¢ããªã±ã¼ã·ã§ã³ã¨æ¬ãä»ãã¦ããªãã®ã§ãã¢ããªã±ã¼ã·ã§ã³ãã¾ããã§ã¤ãã³ããæ¿å ¥ã§ãããADBã§ã¹ã¯ãªã¼ã³ã·ã§ãããæ®ããããNativeDriverãæ¹è¯ããã«ã¤ãã¦æ°ããããæ¹ã§ä½¿ã£ã¦ããäºå®ãæ¨æºã®Instrumentationãã¹ããããAndroidã®NativeDriverã®ãã¹ããå¼·åãªçç±ã§ãããã
Androidã®NativeDriverã¯ä»ãã試ããããサンプルテストを走らせたりã自分のアプリにInstrumentationを入れãããããã¨ãユーザMLã¨開発者MLã«åå ãã¦ã
ãã¤ãã£ãã®ãã¹ãã楽ãããªããã£ï¼ããï¼
ææ³: ãã©ã¤ãã¼ã¨ããã¤ãã£ãã£ã¦åèªã®ä½¿ãæ¹ãç°æ¬¡å ã