Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
What's new in testing WWDC2018
Search
yokoya-s000
June 11, 2018
750
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.5k
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Optimizing for Happiness
mojombo
378
71k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
240
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
560
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
Building the Perfect Custom Keyboard
takai
2
890
How to make the Groovebox
asonas
2
2.5k
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