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

What's new in testing WWDC2018

yokoya-s000
June 11, 2018
670

What's new in testing WWDC2018

yokoya-s000

June 11, 2018
Tweet

Transcript

  1. ◾ ·ͱΊ ◾ Code Coverage ɾ xccovίϚϯυͰΧόϨοδϨϙʔτΛ͍͍ײ͡ʹͰ͖Δ ◾ Test Selection

    And Ordering ɾ ৽͍͠ςετΛ࣮ߦର৅ʹؚΊΔ/ؚΊͳ͍ Λબ୒Ͱ͖Δ ɾ ςετ͕ϥϯμϜ࣮ߦͰ͖ΔΑ͏ʹͳͬͨɻݎ࿚ੑ61⤴ ◾ Parallel Testing ɾ ฒྻͰςετΛ࣮ߦͰ͖ͯૣ͍
  2. ◾ xccov ▪ xccovίϚϯυͰΧόϨοδϨϙʔτΛৄ͘͠ݟΕΔ $ man xccov NAME xccov -

    view Xcode coverage data in human-readable or machine-parseable format.
  3. ◾ xccov ▪ xccov Λ࢖ͬͯΧόϨοδϨϙʔτΛਓ͕ؒݟΕΔܗͰग़ྗ͢Δ $ xcrun xccov view XXXX.xccovreport

    Name Coverage ------------------------------------------------------------------ --------------- HelloWorld.app 57.89% (11/19) /tmp/HelloWorld/HelloWorld/AppDelegate.m 50.00% (3/6) -[AppDelegate applicationWillTerminate:] 0.00% (0/3) -[AppDelegate applicationDidFinishLaunching:] 100.00% (3/3) /tmp/HelloWorld/HelloWorld/ViewController.m 50.00% (5/10) -[ViewController setRepresentedObject:] 0.00% (0/5) -[ViewController viewDidLoad] 100.00% (5/5) /tmp/HelloWorld/HelloWorld/main.m 100.00% (3/3) main
  4. ◾ xccov ▪ xccov Φϓγϣϯ xccov view --json XXXX.xccovreport ɾKTPOܗࣜͰग़ྗ

    xccov view --file-list XXXX.xccovarchive/ ɾΧόϨοδσʔλΛ࣋ͭ͢΂ͯͷϑΝΠϧΛҰཡදࣔ xccov view --file /tmp/HelloWorld/HelloWorldTests/HelloWorldTests.m XXXX.xccovarchive/` ɾ̍ϑΝΠϧͷΧόϨοδ͚ͩग़ྗ Լͭͷ࢖͍ॴ͕Α͘Θ͔Βͳ͍...
  5. ◾ Test “Selection” εΩʔϜผʹ৽͘͠௥Ճͨ͠ςετΛ࣮ߦ͢Δ/͠ͳ͍Λબ΂Δ ɾEdit Scheme -> Test -> Info

    -> Options -> Automatically includes new tests ▪ ׆༻ྫ ɾUIςετ͸φΠτϦʔϏϧυͰར༻͢ΔεΩʔϜͷΈ Automatically includes new tests Λ ON ʹ͢Δ
  6. ◾ Test “Ordering” XCTestCase ͷαϒΫϥε୯Ґ ͰɺςετΛϥϯμϜ࣮ߦ͢Δ ※ࠓ·Ͱ͸ΞϧϑΝϕοτॱͩͬͨ ɾEdit Scheme ->

    Test -> Info -> Options -> Randomize execution order ▪ ར఺ ɾຖճಉ͡ॱ൪ͩͱʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͷଘࡏʹؾ͚ͮͳ͍
  7. ◾ Test “Ordering” ▪ ʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͱ͸ʁ ҎԼͷͭͷςετΫϥε͕͋ͬͨͱ͠·͢ɻ ɾATestsΫϥε: UserςʔϒϧΛ࡞੒ ɾBTestsΫϥε: Userςʔϒϧ΁௥Ճ

    ɾCTestsΫϥε: Userςʔϒϧͷ࡟আ ্هςετ͸ɺ A->B->C ͷॱ൪ʹ࣮ߦͨ࣌͠͸੒ޭ͠·͢ɻ ͔͠͠ɺ B,C͔Β࢝·Δͱࣦഊ͠·͢ɻ
  8. ◾ Test “Ordering” ▪ ʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͱ͸ʁ ɾຊ౰͸ ࣦഊ͢΂͖ςετ ͕੒ޭͯ͠͠·͍ͬͯΔɻ ɾςετؒʹ ґଘ

    ͕͋ΔͷʹɺͦΕΛݕग़Ͱ͖͍ͯͳ͍ɻ ϥϯμϜ࣮ߦͰʮͨ·ͨ·͏·͍ͬͯ͘ΔςετʯΛແ͘͢ ݎ࿚ੑ61⤴
  9. ◾ Parallel Testing ※ࠓ·Ͱͷ1BSBMMFM Testing γϛϡϨʔλΛෳ਺ ্ཱͪ͛ͯฒྻ࣮ߦ ▪ Parallel “Destination”

    Testing xcodebuild test -destination ‘platform=iOS,name=iPhone X’ -destination ‘platform=iOS,name=iPad’
  10. ◾ Parallel Testing ※ࠓ·Ͱͷ1BSBMMFM Testing γϛϡϨʔλΛෳ਺ ্ཱͪ͛ͯฒྻ࣮ߦ ▪ Parallel “Destination”

    Testing xcodebuild test -destination ‘platform=iOS,name=iPhone X’ -destination ‘platform=iOS,name=iPad’ ɾiPhone X ͱ iPad ͷ γϛϡϨʔλͰฒྻ࣮ߦ ɾ֤γϛϡϨʔλͰ࣮ߦ͢Δςετέʔε͸ಉ͡
  11. ◾ Parallel Testing ※৽͍͠1BSBMMFM Testing ̍ͭͷγϛϡϨʔλͷ ΫϩʔϯΛෳ਺ ্ཱͪ͛ͯฒྻ࣮ߦ ɾiPhone X

    ͷΫϩʔϯΛෳ਺্ཱͪ͛ͯฒྻ࣮ߦ ɾ֤ΫϩʔϯͰ ςετέʔεΛ෼୲ͯ͠ ࣮ߦ͢Δ ɾૣ͍ ▪ Parallel “Distributed” Testing
  12. ◾ Parallel “Distributed” Testing ▪ ֤ΫϩʔϯͰςετέʔεΛ෼୲࣮ͯ͠ߦ͢Δ TestClass TestClass TestClass TestClass

    ֤ΫϩʔϯͰࢀর͢ΔϑΝΠϧ͸෼͔Ε͍ͯΔͷͰɺ ʮଞͷΫϩʔϯ͕ઌʹϑΝΠϧ"Λ࿔͚ͬͨ࣌ͩςετ͕མͪΔ…ʯ ͱ͍͏Α͏ͳ͜ͱ͸ແ͍ɻ
  13. ◾ Parallel “Distributed” Testing ▪ xcodebuild ίϚϯυͰɺฒྻςετʹؔ͢ΔΦϓγϣϯΛมߋͰ ͖Δ -parallel-testing-worker-count n

    ɾฒྻςετதʹੜ੒͞ΕΔςετϥϯφʔͷ਺ -parallel-testing-enabled YES | NO ɾεΩʔϜͷλʔήοτ͝ͱͷઃఆΛ্ॻ͖͢Δ -maximum-concurrent-test-device-destinations n ɾಉ࣌ʹςετ͢ΔσόΠεѼઌͷ࠷େ਺ -maximum-concurrent-test-simulator-destinations n ɾಉ࣌ʹςετ͢ΔγϛϡϨʔλѼઌͷ࠷େ਺
  14. ◾ Testing Tips & Tricks ͔Βͷൈਮ ... Λ͠Α͏ͱࢥ͚ͬͨͲ͕࣌ؒ଍Γͳͦ͏ɻ Optimazation App

    Launch When Testing("Testing Tips & Tricks"ͷ 34: 57 ~) ͸ྑ͛͞ͳΞϓϩʔνͰͨ͠(ײ૝) ɾεΩʔϜ͝ͱʹ؀ڥม਺Λࢦఆ͠ɺʮ୯ମςετ࣌ʹෆཁͳॲཧ͸࣮ߦ͠ͳ͍ʯͳͲ Λߦ͏͜ͱͰςετΛૣ͘͢Δ