Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
What's new in testing WWDC2018
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
yokoya-s000
June 11, 2018
740
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
What's new in testing WWDC2018
yokoya-s000
June 11, 2018
More Decks by yokoya-s000
See All by yokoya-s000
単体テストのハジメ
yokoyas000
13
4.4k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
GitHub's CSS Performance
jonrohan
1033
470k
Exploring anti-patterns in Rails
aemeredith
3
390
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
320
Code Reviewing Like a Champion
maltzj
528
40k
Test your architecture with Archunit
thirion
1
2.3k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
360
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
30 Presentation Tips
portentint
PRO
1
320
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Transcript
What’s new in Testing WWDC18 #wwdc_rusuban 2018/06/11 @yokoyas000
◾ ·ͱΊ ◾ Code Coverage ɾ xccovίϚϯυͰΧόϨοδϨϙʔτΛ͍͍ײ͡ʹͰ͖Δ ◾ Test Selection
And Ordering ɾ ৽͍͠ςετΛ࣮ߦରʹؚΊΔ/ؚΊͳ͍ ΛબͰ͖Δ ɾ ςετ͕ϥϯμϜ࣮ߦͰ͖ΔΑ͏ʹͳͬͨɻݎ࿚ੑ61⤴ ◾ Parallel Testing ɾ ฒྻͰςετΛ࣮ߦͰ͖ͯૣ͍
Code Coverage
◾ Code Coverage ※ Ҏલ͔Β͋Δػೳ ذॲཧΛςετͰͲΕ͚ͩཏͰ͖ͯΔ͔ݟΕΔػೳ
◾ Code Coverage ▪ Code coverage Λ༗ޮʹͨ͠ঢ়ଶͰςετ࣮ߦͨ͠ޙ ɾςετͰ࣮ߦ͞Εͨߦ ɾςετͰ࣮ߦ͞Εͳ͔ͬͨߦ
◾ Code Coverage(Xcode 9.3 ~) ▪ ύϑΥʔϚϯεͱਖ਼֬͞ͷվળ ▪ ςετλʔήοτΛબΔ ▪
xccovίϚϯυͰΧόϨοδใΛݟΕΔ
◾ Code Coverage(Xcode 9.3 ~) ▪ ύϑΥʔϚϯεͱਖ਼֬͞ͷվળ ▪ ςετλʔήοτΛબΔ ▪
xccovίϚϯυͰΧόϨοδใΛݟΕΔ
◾ xccov ▪ xccov ΧόϨοδϨϙʔτΛͬͯͳΜ͔ΜͰ͖ΔίϚϯυ ▪ ΧόϨοδϨϙʔτ ΧόϨοδΛ༗ޮʹͨ͠ঢ়ଶͰςετΛ࣮ߦ͢Δͱੜ͞ΕΔϑΝΠϧ ɾ.xccovreport֦ுࢠ ɾΧόϨοδͷׂ߹͕ॻ͔Ε͍ͯΔ
ɾ.xccovarchive֦ுࢠ ɾ ΞϓϦέʔγϣϯίʔυͷ֤ϑΝΠϧͷ࣮ߦΧϯτ
◾ xccov ▪ xccovίϚϯυͰΧόϨοδϨϙʔτΛৄ͘͠ݟΕΔ $ man xccov NAME xccov -
view Xcode coverage data in human-readable or machine-parseable format.
◾ 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
◾ xccov ▪ xccov Φϓγϣϯ xccov view --json XXXX.xccovreport ɾKTPOܗࣜͰग़ྗ
xccov view --file-list XXXX.xccovarchive/ ɾΧόϨοδσʔλΛ࣋ͭͯ͢ͷϑΝΠϧΛҰཡදࣔ xccov view --file /tmp/HelloWorld/HelloWorldTests/HelloWorldTests.m XXXX.xccovarchive/` ɾ̍ϑΝΠϧͷΧόϨοδ͚ͩग़ྗ Լͭͷ͍ॴ͕Α͘Θ͔Βͳ͍...
Test Selection And Ordering
◾ Test Selection And Ordering ※ Xcode 10 ͔Βͷ৽ػೳ ▪
Test Selection ▪ Test Ordering
◾ Test Selection And Ordering ▪ Test Selection ▪ Test
Ordering
◾ Test “Selection” εΩʔϜผʹ৽͘͠Ճͨ͠ςετΛ࣮ߦ͢Δ/͠ͳ͍ΛબΔ ɾEdit Scheme -> Test -> Info
-> Options -> Automatically includes new tests ▪ ׆༻ྫ ɾUIςετφΠτϦʔϏϧυͰར༻͢ΔεΩʔϜͷΈ Automatically includes new tests Λ ON ʹ͢Δ
◾ Test Selection And Ordering ▪ Test Selection ▪ Test
Ordering
◾ Test “Ordering” XCTestCase ͷαϒΫϥε୯Ґ ͰɺςετΛϥϯμϜ࣮ߦ͢Δ ※ࠓ·ͰΞϧϑΝϕοτॱͩͬͨ ɾEdit Scheme ->
Test -> Info -> Options -> Randomize execution order ▪ ར ɾຖճಉ͡ॱ൪ͩͱʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͷଘࡏʹؾ͚ͮͳ͍
◾ Test “Ordering” ▪ ʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͱʁ ҎԼͷͭͷςετΫϥε͕͋ͬͨͱ͠·͢ɻ ɾATestsΫϥε: UserςʔϒϧΛ࡞ ɾBTestsΫϥε: UserςʔϒϧՃ
ɾCTestsΫϥε: Userςʔϒϧͷআ ্هςετɺ A->B->C ͷॱ൪ʹ࣮ߦͨ࣌͠ޭ͠·͢ɻ ͔͠͠ɺ B,C͔Β࢝·Δͱࣦഊ͠·͢ɻ
◾ Test “Ordering” ▪ ʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͱʁ ɾຊ ࣦഊ͖͢ςετ ͕ޭͯ͠͠·͍ͬͯΔɻ ɾςετؒʹ ґଘ
͕͋ΔͷʹɺͦΕΛݕग़Ͱ͖͍ͯͳ͍ɻ
◾ Test “Ordering” ▪ ʮͨ·ͨ·͏·͍ͬͯ͘Δςετʯͱʁ ɾຊ ࣦഊ͖͢ςετ ͕ޭͯ͠͠·͍ͬͯΔɻ ɾςετؒʹ ґଘ
͕͋ΔͷʹɺͦΕΛݕग़Ͱ͖͍ͯͳ͍ɻ ϥϯμϜ࣮ߦͰʮͨ·ͨ·͏·͍ͬͯ͘ΔςετʯΛແ͘͢ ݎ࿚ੑ61⤴
◾ Test “Ordering” ɾςετؒͰґଘ͕ແ͍Α͏ʹ͠·͠ΐ͏ ɾࣄલ/ࣄޙॲཧ͕ඞཁͰ͋ΕɺTFUVQ teardown Λ͍·͠ΐ͏
Parallel Testing
◾ Parallel Testing ※ࠓ·Ͱͷ1BSBMMFM Testing γϛϡϨʔλΛෳ ্ཱͪ͛ͯฒྻ࣮ߦ ▪ Parallel “Destination”
Testing xcodebuild test -destination ‘platform=iOS,name=iPhone X’ -destination ‘platform=iOS,name=iPad’
◾ Parallel Testing ※ࠓ·Ͱͷ1BSBMMFM Testing γϛϡϨʔλΛෳ ্ཱͪ͛ͯฒྻ࣮ߦ ▪ Parallel “Destination”
Testing xcodebuild test -destination ‘platform=iOS,name=iPhone X’ -destination ‘platform=iOS,name=iPad’ ɾiPhone X ͱ iPad ͷ γϛϡϨʔλͰฒྻ࣮ߦ ɾ֤γϛϡϨʔλͰ࣮ߦ͢Δςετέʔεಉ͡
◾ Parallel Testing ※৽͍͠1BSBMMFM Testing ̍ͭͷγϛϡϨʔλͷ ΫϩʔϯΛෳ ্ཱͪ͛ͯฒྻ࣮ߦ ɾiPhone X
ͷΫϩʔϯΛෳ্ཱͪ͛ͯฒྻ࣮ߦ ɾ֤ΫϩʔϯͰ ςετέʔεΛ୲ͯ͠ ࣮ߦ͢Δ ɾૣ͍ ▪ Parallel “Distributed” Testing
◾ Parallel “Distributed” Testing ▪ ֤ΫϩʔϯͰςετέʔεΛ୲࣮ͯ͠ߦ͢Δ XCTestCase ͷαϒΫϥε୯Ґ Ͱ୲͢Δɻ TestClass
TestClass TestClass TestClass TestClass TestClass
◾ Parallel “Distributed” Testing ▪ ֤ΫϩʔϯͰςετέʔεΛ୲࣮ͯ͠ߦ͢Δ TestClass TestClass TestClass TestClass
֤ΫϩʔϯͰࢀর͢ΔϑΝΠϧ͔Ε͍ͯΔͷͰɺ ʮଞͷΫϩʔϯ͕ઌʹϑΝΠϧ"Λ࿔͚ͬͨ࣌ͩςετ͕མͪΔ…ʯ ͱ͍͏Α͏ͳ͜ͱແ͍ɻ
◾ Parallel “Distributed” Testing ▪ Ϋϥε୯ҐͰόϥόϥʹ͢Δཧ༝ ɾςετΫϥεؒͷґଘΛͳ͘͢(ϥϯμϜςετͱಉ͡) ɾsetup, teardown ͦΕͧΕ̍ճͣͭݺΜͰཉ͍͠
ɾΫϥε୯ҐΑΓখ͘͢͞ΔͱɺTFUVQ teardownΛෳճݺͿ͜ͱʹ…
◾ 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 ɾಉ࣌ʹςετ͢ΔγϛϡϨʔλѼઌͷ࠷େ
◾ Parallel Testing Tips ▪ ̍ͭͷେ͖ͳςετΫϥεͭҎ্ʹׂ͠·͠ΐ͏ ɹɾʮେ͖ͳςετΫϥεʯ͕ऴΘΒͳ͍ݶΓςετऴྃʹͳΒͳ͍ ▪ ύϑΥʔϚϯεςετฒྻςετͱผʹςετ͠·͠ΐ͏ ▪
ύϥϨϧʹ ͍͍ͯͳ͍ ςετΛΓ·͠ΐ͏ ɾʮෳͷΫϩʔϯ͕ ڞ௨ͷ%#ʹΞΫηε͢ΔʯͳͲ
◾ Testing Tips & Tricks ͔Βͷൈਮ ... Λ͠Α͏ͱࢥ͚ͬͨͲ͕࣌ؒΓͳͦ͏ɻ Optimazation App
Launch When Testing("Testing Tips & Tricks"ͷ 34: 57 ~) ྑ͛͞ͳΞϓϩʔνͰͨ͠(ײ) ɾεΩʔϜ͝ͱʹڥมΛࢦఆ͠ɺʮ୯ମςετ࣌ʹෆཁͳॲཧ࣮ߦ͠ͳ͍ʯͳͲ Λߦ͏͜ͱͰςετΛૣ͘͢Δ
What's New in Testing https://developer.apple.com/videos/play/wwdc2018/403 Testing Tips & Tricks https://developer.apple.com/videos/play/wwdc2018/417