What's New in Testing!!!

What's New in Testing!!!

This document is a brief summary of the contents announced at WWDC 2017.

Db5cf21a75ebe2484b95ea9dec5f573b?s=128

Shingo Tamaki

July 19, 2017
Tweet

Transcript

  1. What's New in Testing!!!

  2. ࣗݾ঺հ

  3. ࣗݾ঺հ ۄ৓৴ޛ iOS Engineer! ޷͖ͳframework͸HomeKitͱXCTestͰ͢ झຯ" ిࢠ޻࡞⚡ ےτϨ$ ΨδΣοτ%

  4. Enhancements

  5. xcodebuild • CoreSimulator • Prallel testing

  6. ͜Ε·ͰͷγϛϡϨʔλଟॏىಈ Xcode8.3·Ͱ͸Simulator.appͰͷىಈͰଟॏىಈΛαϙʔτ͠ ͍ͯͳ͔ͬͨɻ FBSimulatorControllͳͲΛ࢖͍CoreSimulatorΛ௚઀ىಈͤ͞ Δํ๏͕͕͋ͬͨɺެࣜʹͦΕΛαϙʔτͨ͠ܗɻ FBSimulatorControl https://github.com/facebook/FBSimulatorControl

  7. FBSimulatorControl

  8. ͦͷଞͷଟॏγϛϡϨʔλଟॏىಈϥΠϒϥϦ FBSimulatorControlΑΓ΋࠶࣮ߦͳͲػೳ͕ଟ͍ͷͰXcode9Ҏ ߱΋࢖ΘΕͦ͏ bluepill https://github.com/linkedin/bluepill

  9. ؓ࿩ٳ୊

  10. Localization ςετ࣌ͷLanguage/Localࢦఆ͕ՄೳʹͳΓ·ͨ͠ɻ

  11. Xcode Server XcodeʹXcode Serverͷػೳ͕͖ͭ·ͨ͠ɻ

  12. Block-based test teardown

  13. Async Testing ඇಉظͷ୯ମͱςετʹ͍ͭͯ͸͜Ε·ͰXCTExpectationΛ ࢖͍ͬͯ·ͨ͠ɻ

  14. Limitations • λΠϜΞ΢τͷ৔߹ඞࣦͣഊͱͯ͠ѻΘΕͯ͠·͍·͢ɻ • ΢ΣΠτॲཧ͕ඞཁͱͳΔ • ΤϥʔͷݪҼ͕ಛఆͮ͠Β͍ • ωετͨ͠΢ΤΠτॲཧ͕ग़དྷͳ͍

  15. XCTWaiter • XCTWaiterͱͯ͠΢ΣΠτॲཧʹؔ͢Δ෦෼͕XCTestCase͔ Β෼཭͠·ͨ͠ɻ • ର৅ͱͳΔexpectationΛ໌ࣔతʹෳ਺Ͱ͖ΔΑ͏ʹͳΓ·͠ ͨɻ • XCTWaiterʹ߹ΘͤͯDelegateΫϥε΋ఆٛ͞Ε·ͨ͠ •

    Returns XCTWaiter.Result
  16. XCTWaiter

  17. XCTWaiter

  18. XCTWaiter.Result XCWaiter.Result͕ఆٛ͞Εɺ࣮ߦ݁Ռͱͯ͠ҎԼͷΑ͏ͳ΋ͷ ͕ఆٛ͞Ε͍ͯ·͢ɻ • completed • timedOut • incorrectOrder •

    invertedFulfillment • interrupted
  19. XCTTestExpectation XCTWaiterʹ߹ΘͤͯXCTTestExpectation΋֦ு͞Ε·ͨ͠ɻ (Xcode8.3Ͱ௥Ճ) • ΠχγϟϥΠβ͕͖ͭ·ͨ͠ • expectationDescriptionͰDescriptionͷมߋ͕ग़དྷΔ Α͏ʹͳΓ·ͨ͠ɻ • expectedFulfillmentCountͷઃఆʹΑͬͯɺfulfill()ͷճ਺ʹ

    ΑΔࢦఆ͕ग़དྷΔΑ͏ʹͳΓ·ͨ͠ɻͭ·Γ
  20. XCTTestExpectation • isInvertedϓϩύςΟʹΑͬͯςετͷ੒ޭ/ࣦഊΛٯస͞ ͤΔ͜ͱ͕ग़དྷ·͢ɻ͜ΕͰλΠϜΞ΢τͰ΋੒ޭͱ͢Δ͜ ͱ͕Ͱ͖·͢Ͷɻ • wait(for:timeout:enforceOrder:)ͷΑ͏ʹexpectationͷ ׬ྃॱΛࢦఆ͢Δ͜ͱ͕Ͱ͖·͢

  21. XCTWaiterDelegate • nestedWaiter(_:wasInterruptedByTimedOutWaiter:) • waiter(_:didTimeoutWithUnfulfilledExpectations:) • waiter(_:didFulfillInvertedExpectation:) • waiter(_:fulfillmentDidViolateOrderingConstraintsFor:requir edExpectation:)

  22. Multi-app Testing

  23. Multi-app Testing UI Testing͸͜Ε·Ͱ1ͭͷΞϓϦέʔγϣϯʹରͯ͠ߦ͏΋ͷ Ͱͨ͠ɺ͔͠͠Xcode9͔Βىಈର৅ͷΞϓϦΛࢦఆ͢ΔࣄͰෳ ਺ΞϓϦͷىಈ͕UI TestingͰߦ͑ΔΑ͏ʹͳΓ·ͨ͠ɻ

  24. XCUIApplication • New initializer • init(bundleIdentifier: String)Ͱର৅ΞϓϦͷ BundleIDΛࢦఆ • init(url:

    URL)΋௥Ճ͞Ε·͕ͨ͠MacOSͷΈͳͷͰઆ ໌লུ(ௐ΂ͯͳ͍)
  25. XCUIApplication • Activate • ΞϓϦ͸launch()Ͱىಈ͠·͕͢ɺෳ਺ΞϓϦΛίϯτ ϩʔϧ͢Δࡍɺactivate()Λ࢖͏͜ͱʹΑͬͯΞϓϦͷ ੾Γସ͑Λߦ͍·͢ɻ • State property

    • ෳ਺ͷΞϓϦΛ੾Γସ͑ͨΓ͢Δ͜ͱΛ૝ఆ͢Δʹ͋ͨ ΓɺΞϓϦͷঢ়ଶΛఆٛͨ͠ϓϩύςΟ͕௥Ճ͞Ε·ͨ͠
  26. XCUIApplication

  27. UI Testing performance

  28. FirstMatch API firstMatchΛ࢖͏͜ͱͰͰUIElementͷݕࡧʹஔ͍ͯ࠷ॳʹݟ ͚ͭͨ࣌఺ͰݕࡧΛൈ͚Δࣄ͕ग़དྷΔΑ͏ʹͳΓ·ͨ͠ɻ

  29. FirstMatch API ౰વͰ͕͢ɺۃྗཁૉΛߜΔ৚݅͸ࡉ͔͍ํ͕ྑ͍Ͱ͢ɻ

  30. Activities, attachments, and screenshots

  31. Activities ςετͷखॱΛϒϩοΫͰแΜͰ໊લΛ͚ͭΔ͜ͱ͕ग़དྷΔΑ ͏ʹͳΓ·ͨ͠ɻ

  32. ͜Ε·Ͱͷςετ

  33. ͜Ε·Ͱͷςετ

  34. ͜Ε͔Βͷςετ

  35. ࣮ߦϩά͔Βݟͨҧ͍ ࡉ͔ͳखॱͰ͸ͳ͘γφϦΦͱͯ͠Θ͔Γ΍͍͢ܗʹ

  36. Attachment ςετ࣌ʹ௥Ճͷϩά΍ΠϝʔδͳͲΛ࢒͢͜ͱ͕Ͱ͖ΔΑ͏ ʹͳΓ·ͨ͠ɻ

  37. Screenshots ͜Ε·ͰͷࣗಈεΫϦʔϯγϣοτͰ͸ͳ͘ɺద੾ͳλΠϛϯ άͰεΫϦʔϯγϣοτΛࡱΕΔΑ͏ʹͳΓ·ͨ͠ɻ

  38. Screenshots

  39. Attachment Lifetime Policies εΫϦʔϯγϣοτ΍Ξλονϝϯτ͸ςετ׬ྃ࣌ʹ࡟আ͢ ΔͳͲͷઃఆ΋ՄೳʹͳΓ·͢ɻ

  40. https:// developer.apple.com /videos/play/ wwdc2017/409/

  41. Ҏ্