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

みんな使おう! AWS Device Farm

53e2d354b3299d64a54af680865516d5?s=47 Sato Takeshi
February 23, 2017

みんな使おう! AWS Device Farm

GEEK GARAGE iOS vol1
https://geekgarage.connpass.com/event/50929/
の資料です。

53e2d354b3299d64a54af680865516d5?s=128

Sato Takeshi

February 23, 2017
Tweet

More Decks by Sato Takeshi

Other Decks in Technology

Transcript

  1. ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017೥2݄23೔ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23

    1
  2. ࣗݾ঺հ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 2

  3. ࠤ౻߶࢜(@hatakenokakashi) SIاۀͷอकӡ༻͔ΒɺελʔτΞοϓͷCTOΛܦͯɺ MAMORIOגࣜձࣾʹ2݄͔ΒiOSΤϯδχΞΛ͍ͯ͠·͢ɻ RailsͱJavaScript(ES6)ͱGolangͱ༑ୡʹͳΔͷ͕ࠓ೥ͷ໨ඪɻ ίʔώʔͱϛϯτςΟ͕޷͖ɻ ϒϩάɿhttp://blog.personal-factory.com/ ΈΜͳ࢖͓͏ʂ AWS Device Farm

    2017/2/23 3
  4. ςετͭΒ͍ͬ͢ΑͶ! ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 4

  5. ։ൃ͸ͲΜͲΜਐΉ ͦͷͨͼʹશ୺຤Λςετ͠ͳ͖Ό͍ ͚ͳ͍ɻ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 5

  6. ͦ͜ʹཱͪ͸͹͔Δ໰୊ • ୺຤༻ҙ͕େม • ૿େ͢Δςετ޻਺ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23

    6
  7. Ͳ͏͠Α͏(´ɾТɾʆ) ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 7

  8. ͦ͜ͰԞ͞Μʂ Device Farmͷग़൪Ͱ͢ʂ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 8

  9. Device FarmͬͯԿʁ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 9

  10. Device Farm • AWSͷεϚϑΥ&WebΞϓϦ޲͚ςετࣗಈԽαʔϏε • iOSɺAndroid֤୺຤֤OSόʔδϣϯΛऔΓἧ͑Δ • ࠷ॳͷ߹ܭ250෼·Ͱແྉɻޙ0.17 USD/෼ ΈΜͳ࢖͓͏ʂ

    AWS Device Farm 2017/2/23 10
  11. ๛෋ͳ୺຤छྨ&OSόʔδϣϯ • iPhone4s-iPhone7PlusͷiOS7.1͔ΒiOS10·Ͱ • iPad2/iPad miniୈҰੈ୅/iPad Pro • Android΋΄΅ओཁͳ୺຤ΛͦΖ͍͑ͯΔʢͨͩ͠άϩʔόϧ൛) •

    Android୺຤͸೔ຊ͸ΩϟϦΞ͕ΧελϚΠζ͍ͯ͠ΔͷͰ஫ ҙʂ https://aws.amazon.com/jp/device-farm/device-list/ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 11
  12. ͲΜͳςετ͕Ͱ͖Δ͔ʁ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 12

  13. Fuzz • DeviceFarmʹ༧Ί༻ҙ͞Ε͍ͯΔϑϨʔϜϫʔΫ • σλϥϝʹUIΞΫγϣϯΛ࣮ߦ͢Δɻ • ϞϯΩʔςετͱͯ͠ΞϓϦ͕མͪͳ͍͔Ͳ͏͔νΣοΫͰ ͖Δɻ ΈΜͳ࢖͓͏ʂ AWS

    Device Farm 2017/2/23 13
  14. Appium • Java JUnitɺJava TestNGɺPython • iOS/AndroidʹରԠ͢ΔςετϑϨʔϜϫʔΫɻ • Appiumࣗମ͸༷ʑͳݴޠͰಈ͚͘ͲDeviceFarmͰ͸ରԠ͠ ͍ͯΔͷ͸JavaͱPythonͷΈɻ

    ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 14
  15. Calabash • Xamarin͕ࣾϝϯςϯφεΛ͍ͯ͠ΔΦʔϓϯιʔεςετϑ ϨʔϜϫʔΫ • iOS/AndroidʹରԠ • RubyͰಈ͘ ΈΜͳ࢖͓͏ʂ AWS

    Device Farm 2017/2/23 15
  16. UI Automation(Xcode7·Ͱ) • Xcodeʹ͍ͭͯ͘ΔInstrumentsʹ෇ଐ͢ΔςετϑϨʔϜϫ ʔΫ • iOSʹରԠ • JavaScriptͰiOSΞϓϦͷUIΛૢ࡞Ͱ͖Δɻ •

    Xcode8͔Β͸Instruments͔Β࡟আ͞Ε࢖༻Ͱ͖ͳ͍ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 16
  17. XCTest (XCUI ͓Αͼ KIF ΛؚΉ) • Xcodeʹ෇ଐ͢ΔiOSΞϓϦͷςετϑϨʔϜϫʔΫ • Ϣχοτςετ͕XCTest •

    UIςετΛ͢Δʹ͸XCUI ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 17
  18. AndroidͷςετϑϨʔϜϫʔΫ • Instrumentation • UI Automator • JUnit • Espresso

    • Robotium ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 18
  19. ࢼͯ͠ΈΔ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 19

  20. XCUIͰ࢖ͬͯΈΔ 1. ΞϓϦΛϏϧυ͢Δ 2. XCUIΛϏϧυ͢Δ 3. Payload.ipaϑΝΠϧΛͭ͘Δ 4. Device FarmʹΞϓϦͱςετΛొ࿥࣮͠ߦ

    5. ςετ݁ՌΛΈΔ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 20
  21. ΞϓϦΛϏϧυ͢Δ XcodeͷProduct -> ArchiveͰΞʔΧΠ ϒ OrganaizerϖʔδͰExport ΈΜͳ࢖͓͏ʂ AWS Device Farm

    2017/2/23 21
  22. Save for Development DeploymentΛ બ୒ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23

    22
  23. Device SupportΛExport one app for all compatible devicesʹબ୒ ΈΜͳ࢖͓͏ʂ AWS

    Device Farm 2017/2/23 23
  24. XCUIͰςετίʔυΛॻ͘ import XCTest class MAMORIOUITests: XCTestCase { override func setUp()

    { super.setUp() continueAfterFailure = false XCUIApplication().launch() } func test1Tutorial() {} } ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 24
  25. XCUIΛϏϧυ͢Δ Product > Build For > Testing ΈΜͳ࢖͓͏ʂ AWS Device

    Farm 2017/2/23 25
  26. [UITestName]-Runner.appΛऔಘ ϏϧυύεΛݟΔ /Users/<UserName>/Library/ Developer/Xcode/DerivedData/ <App Name>-xxxxxxxxxxxxxxxxx/ Build/Products/Debug-iphoneos/ ΈΜͳ࢖͓͏ʂ AWS Device

    Farm 2017/2/23 26
  27. ιʔεҰཡͷ Products >ɹ[APPNAME].app ΛӈΫϦοΫͰFinderΛ։͍ͯ΋ྑ͍ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 27

  28. Payload.ipaϑΝΠϧΛͭ͘Δ 1. PayloadσΟϨΫτϦΛ࡞Γ[UITestName]-Runner.appΛೖΕ Δɻ 2. ͦͷޙʹzipͰPayloadσΟϨΫτϦΛѹॖ͢Δɻ 3. Payload.zipΛPayload.ipaʹϦωʔϜ͢Δɻ ΈΜͳ࢖͓͏ʂ AWS

    Device Farm 2017/2/23 28
  29. mkdir Payload mv [UITestName]-Runner.app Payload zip Payload.zip Payload mv Payload.zip

    Payload.ipa ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 29
  30. Device FarmʹΞϓϦͱςε τΛొ࿥࣮͠ߦ Create a new project ΛΫϦοΫ Create a

    new run ΛΫϦοΫ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 30
  31. ΞϓϦͷipaϑΝΠϧ ΛΞοϓϩʔυ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 31

  32. XCTest UIΛબΜͰ Payload.ipaΛΞοϓ ϩʔυ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 32

  33. DeviceΛબͼ·͢ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 33

  34. DeviceͷৄࡉΛ͠·͢ ϩέʔγϣϯΛJapanʹ͢Ε͹͍͍ͱࢥ ͏ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 34

  35. DeviceͷλΠϜΞ΢ τઃఆΛ͢Δ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 35

  36. ςετ݁ՌΛΈΔ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 36

  37. DEMO DeviceFarmͷίϯιʔϧ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 37

  38. XCUIͷઆ໌ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 38

  39. XCUIͷઆ໌ • XCUIApplicationͰΞϓϦऔಘͯ͠ • XCUIElementQueryͰUI෦඼Λݕࡧ ͯ͠ • XCUIElementͰλοϓͳͲUIૢ࡞Λ ͢Δ let

    app = XCUIApplication() app.buttons["startButton"].tap() ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 39
  40. XCUIElementQueryͰݕࡧ Ͱ͖ΔΑ͏ʹ accessibilityIdentifierΛઃఆ͠·͠ΐ ͏ɻ Storyboard͸͜Ε ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23

    40
  41. ίʔυ͸ͪ͜Β let title : UILabel = UILabel.init(frame:CGRect(x:0 ,y:0, width:100, height:90))

    title.isAccessibilityElement = true title.accessibilityIdentifier = "logoutLabel" ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 41
  42. XCUIͰTips 1. γεςϜΞϥʔτͷλοϓํ๏(ϓογϡ௨஌ڐՄɺϩέʔγ ϣϯڐՄ) 2. webαΠτͷදࣔ(openͰ։͘ͱ໭Εͳ͍ɻwebViewͰදࣔ ͠Α͏) 3. XCUIͷςετ࣮ߦॱ(ϝιου໊ͷιʔτ) 4.

    Device Farmͷ࣮ߦॱ(ϝιου࣮૷ͷԼ͔Β࣮ߦ͞ΕΔ) ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 42
  43. γεςϜΞϥʔτͷλοϓํ ๏(ϓογϡ௨஌ڐՄɺϩέʔ γϣϯڐՄ) ͜Ε͸ͩΊ let app = XCUIApplication() let notifiAlert

    = app.alerts["“MAMORIO”͸௨஌Λૹ৴͠·͢ɻΑΖ͍͠Ͱ͔͢?"] let comfirmButton = notifiAlert.buttons["ڐՄ"] if comfirmButton.exists { comfirmButton.tap() } ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 43
  44. addUIInterruptionMonitor ϝιουΛ࣮ߦ͢Δඞཁ͕͋Δ //͜Ε͕ඞཁ addUIInterruptionMonitor(withDescription: "notificationAlert", handler: { alert in if

    alert.buttons["ڐՄ"].exists { alert.buttons["ڐՄ"].tap() return true } if alert.buttons["Allow"].exists { alert.buttons["Allow"].tap() return true } return false }) app.tap() ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 44
  45. webαΠτͷදࣔ UIApplicationͷopenͰSafariΞϓϦΛ։͘ͱ໭Εͳ͍ɻ func linkURL(string :String) { if let url =

    URL(string:string) { if #available(iOS 10.0, *) { UIApplication.shared.open(url) } else { UIApplication.shared.openURL(url) } } } ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 45
  46. WebViewͰදࣔ͠Α͏ɻ if let url = URL(string:string) { if let rootViewController

    = self.keyWindow?.rootViewController { let safariViewController = SFSafariViewController.init(url: url) rootViewController.present(safariViewController, animated: true, completion: nil) } } ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 46
  47. XCUIͷςετ࣮ߦॱ XCTestCaseͷςετͷ࣮ߦॱ͸ϝιου໊ͷঢॱɻ ॳճىಈ΍Ϣʔβʔొ࿥ͳͲ࣮ߦॱ͕େࣄʹͳΔ৔߹ʹؾΛͭ ͚Δɻ func test4PasswordReset(){} func test3RegisterUser(){} func test2TemporaryLogin(){}

    func test1Tutorial() {} ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 47
  48. Device Farmͷ࣮ߦॱ ϝιου࣮૷ॱͷԼ͔Β࣮ߦ͞ΕΔɻ ϝιου໊ͷঢॱͰ͸ͳ͍ͷͰ஫ҙʂ func test4PasswordReset(){} func test3RegisterUser(){} func test2TemporaryLogin(){}

    func test1Tutorial() {} ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 48
  49. Α͍ςετϥΠϑΛա͝ ͠·͠ΐ͏✨ ΈΜͳ࢖͓͏ʂ AWS Device Farm 2017/2/23 49