Upgrade to Pro — share decks privately, control downloads, hide ads and more …

uiautomatorでテスト自動化を始める前に知っておくと良いこと

 uiautomatorでテスト自動化を始める前に知っておくと良いこと

ABC 2014 WinterのLTセッションで発表した資料です。

TOYAMA Sumio

December 21, 2014
Tweet

More Decks by TOYAMA Sumio

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ •  ࢯ໊:  ֎ࢁ७ੜ(TOYAMA  Sumio)   @sumio_tym  (twitter),  @sumio  (github)

      •  ॴଐ:  NTTιϑτ΢ΣΞגࣜձࣾ   •  ۀ຿಺༰:   – ࣾ಺Androidؔ࿈ϓϩδΣΫτٕज़ࢧԉ   •  ϓϥΠϕʔτ:   – STAR(ςετࣗಈԽݚڀձ)   – uiautomator΢Υονϟʔ(?)   – uiautomatorͷهࣄ΋ॻ͖·ͨ͠   •  http://www.atmarkit.co.jp/ait/articles/1410/07/news029.html   •  http://www.atmarkit.co.jp/ait/articles/1411/05/news038.html   2  
  2. •  Android  SDKඪ४ͷUIςετࣗಈԽπʔϧ   http://developer.android.com/tools/testing/testing_ui.html   •  apk͕खݩʹແͯ͘΋ૢ࡞Ͱ͖Δ   – ΞϓϦʹ·͕ͨͬͨૢ࡞΋OK!

      – ϓϦΠϯΞϓϦ΋OK!   •  Android  4.1Ҏ্ରԠ   •  WebViewͷૢ࡞͸ෆՄ 3   uiautomatorͬͯ? AndroidόʔδϣϯผγΣΞ(2014/12/1·Ͱͷ7೔ؒͷ౷ܭ)   https://developer.android.com/about/dashboards/index.htmlΑΓҾ༻ 82.6% ࢖ͬͯΈͨ͘ͳΓ·ͤΜ͔?
  3. جຊతͳ࢖͍͔ͨ(1/2)   •  ʮOKϘλϯʯΛԡ͢ྫ   7   UiSelector criteria =

    new UiSelector() .className(Button.class) .text("OK"); UiObject okButton = new UiObject(criteria); okButton.click(); ݕࡧ৚݅Λߏங ৚݅ʹ߹͏UI෦඼   Λ୳ͯ͠ΫϦοΫ!
  4. ςετ։࢝࣌ʹ   ΞϓϦΛىಈ͠௚͢(2/2)   •  amίϚϯυΛςετεΫϦϓτ಺෦͔Β ࣮ߦ͢Δͷ͕؆୯!   11  

    Process p = new ProcessBuilder("am", "start", "-S", "-W", "-a", Intent.ACTION_MAIN, "-n", "<ύοέʔδ໊>/<Activity>") .start(); p.waitFor();
  5. •  จࣈྻೖྗʹ࢖͏UiObject.setText(String)   –  Virtual  Keyboard  Device(=QWERTYΩʔϘʔυ)ͷ   ΩʔΠϕϯτΛٖࣅతʹൃੜͤ͞Δ͜ͱͰೖྗΛ࣮ݱ  

    ೔ຊޠςΩετͷೖྗ(1/2) •  (΄΅)ASCIIҎ֎ΛؚΉจࣈྻೖྗ͸ແࢹ͞ΕΔ!   •  ಈ࡞தͷIMEʹӨڹ͞ΕΔ!   ೔ຊޠ   IME Android   ΩʔϘʔυ setText("aiueo"); http://source.android.com/devices/tech/input/key-­‐character-­‐map-­‐files.html 13  
  6. ೔ຊޠςΩετͷೖྗ(2/2) Uiautomator  Unicode    Input  Helper  (IME) [&MFMwkzBrMGEwbw-­‐!]   Λ[͜Μʹͪ͸!]ʹม׵

      14   •  ASCIIจࣈྻ͔ΒUnicodeʹม׵͢ΔIMEΛ࢖͏   (࡞Γ·ͨ͠)   Uiautomator  Unicode  Input  Helper   https://github.com/sumio/uiautomator-­‐unicode-­‐input-­‐helper   setText( Utf7ImeHelper.e("͜Μʹͪ͸!") ); "&MFMwkzBrMGEwbw-­‐!"͕ฦΔ
  7. ΑΓৄ͘͠͸ •  ҎԼͷهࣄ(ˏITʹͯެ։)Λ͝ࢀর͍ͩ͘͞   –  ʮAndroid  SDKඪ४ͷԿͰ΋ςετπʔϧuiautomatorͷ جຊతͳ࢖͍ํʯ   http://www.atmarkit.co.jp/ait/articles/1410/07/news029.html

      –  ʮAndroidςετͰศརͳuiautomatorviewerɺ UiScrollableͷ࢖͍ํɺςΩετೖྗAPI੍ݶࣄ߲ͷ   ճආํ๏ʯ   http://www.atmarkit.co.jp/ait/articles/1411/05/news038.html   15   ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ ˞STAR(ςετࣗಈԽݚڀձ)ͷ׆ಈͷҰ؀ͱͯࣥ͠ච͠·ͨ͠